简体   繁体   English

安装了react-redux和redux模块的连接反应路由器无法解析模块'react-redux'

[英]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. 我正在尝试使用connected-react-router模块。

From the docs, this is my code in the reducer: 从文档中,这是我在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' ./node_modules/connected-react-router/esm/ConnectedRouter.js找不到模块:无法在'C:\\ Users \\ ericn \\ Documents \\ ReactJS \\ test \\ node_modules \\ connected-react-router中解析'react-redux' \\ 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 . 我意识到我忘了添加react-redux作为对我项目的依赖,我只添加了react

So confirm that you have react-redux in your package.json and it is installed in your node_modules. 因此,请确认您的package.json中已包含react-redux并将其安装在node_modules中。 If not you can run: 如果没有,您可以运行:

npm install --save react-redux

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

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

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