简体   繁体   English

如何修复 react-redux 解决问题?

[英]How can I fix react-redux resolve problem?

I recently study about redux.最近在研究redux。

I install redux below我在下面安装redux

npm install -save redux @types/react-redux

I keep try to fix this problem... but is not working我一直在尝试解决此问题...但无法正常工作

This is my dependencies这是我的依赖

"dependencies": {
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/react": "^11.1.0",
    "@testing-library/user-event": "^12.1.10",
    "@types/jest": "^26.0.15",
    "@types/react": "16.14.2",
    "@types/react-dom": "16.9.10",
    "@types/react-redux": "7.1.14",
    "firebase": "8.2.0",
    "node-sass": "4.14.1",
    "query-string": "6.13.7",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-router-dom": "5.2.0",
    "react-scripts": "4.0.1",
    "redux": "4.0.5",
    "typescript": "^4.0.3",
    "web-vitals": "^0.2.4"
  },

error错误

./src/index.tsx
Modules not found : Can't resolve 'react-redux' ...

and this is my index.tsx这是我的 index.tsx

import React from 'react';
import ReactDOM from 'react-dom';
import rootReducer from './testsrc/modules';
import {createStore} from 'redux';
import {Provider} from 'react-redux';
import CounterContainer from './testsrc/container/CounterContainer';


const store = createStore(rootReducer);


ReactDOM.render(
  <Provider store={store}>
    <CounterContainer/>
  </Provider>,
  
  document.getElementById('root')
);

How can I fix this?我怎样才能解决这个问题?

You just need to install redux and react-redux by running the command您只需要通过运行命令安装reduxreact-redux

  npm install --save redux @types/redux

and

npm install --save react-redux @types/react-redux

you need to install react-redux too.您还需要安装react-redux using this code:使用此代码:

npm install react-redux

Your dependencies doesn't contain a react-redux , therefore your system doesn't see that as installed.您的依赖项不包含react-redux ,因此您的系统看不到它已安装。

Try:尝试:

npm install react-redux

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM