简体   繁体   中英

Can't resolve module 'react-redux' in connected-react-router with react-redux and redux modules installed

I'm trying to use connected-react-router module.

From the docs, this is my code in the reducer:

import { combineReducers } from 'redux';
import login from './loginReducer';
import { connectRouter } from 'connected-react-router'

export default (history) => combineReducers({
  router: connectRouter(history),
  login
});

I'm getting this error in compilation time:

./node_modules/connected-react-router/esm/ConnectedRouter.js Module not found: Can't resolve 'react-redux' in 'C:\\Users\\ericn\\Documents\\ReactJS\\test\\node_modules\\connected-react-router\\esm'

I've been looking for this for a while but none seems to have the same problem.

Any thoughts?

I recently experience a similar error. What I realized was that I forgot to add react-redux as a dependency to my project, I only added react .

So confirm that you have react-redux in your package.json and it is installed in your node_modules. If not you can run:

npm install --save react-redux

// or if you are using yarn
yarn add react-redux

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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