gpt4 book ai didi

reactjs - 找不到模块 : Can't resolve 'redux' in node_modules

转载 作者:搜寻专家 更新时间:2023-10-30 21:33:43 27 4
gpt4 key购买 nike

我在使用typescript创建我的react项目时,引入了Redux报错,提示找不到,但必须安装所有依赖。

这是我的 package.json

{
"name": "react-test",
"version": "0.1.0",
"private": true,
"dependencies": {
"@types/jest": "^24.0.11",
"@types/node": "^11.11.3",
"@types/react": "^16.8.8",
"@types/react-dom": "^16.8.2",
"@types/react-redux": "^7.0.3",
"@types/react-router-dom": "^4.3.1",
"axios": "^0.18.0",
"react": "^16.8.4",
"react-dom": "^16.8.4",
"react-redux": "^6.0.1",
"react-router-dom": "^4.4.0",
"react-scripts": "2.1.8",
"redux": "^4.0.1",
"redux-devtools-extension": "^2.13.8",
"redux-thunk": "^2.3.0",
"typescript": "^3.3.3333"
},
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"devDependencies": {
"babel-plugin-import": "^1.11.0",
"customize-cra": "^0.2.12",
"node-sass": "^4.11.0",
"react-app-rewired": "^2.1.1"
}
}

这是我的商店

import { createStore, applyMiddleware } from 'redux'
import thunk from 'redux-thunk'
import { composeWithDevTools } from 'redux-devtools-extension'

import reducer from './reducer'


const store = createStore(reducer, composeWithDevTools(
applyMiddleware(thunk)
))

不幸的是,该应用程序无法编译并提示:

./node_modules/_react-redux@6.0.1@react-redux/es/connect/mapDispatchToProps.js
Module not found: Can't resolve 'redux' in '~/node_modules/_react-redux@6.0.1@react-redux/es/connect'

我该怎么做才是对的。请帮助我,谢谢。

最佳答案

尝试同时安装 redux 和 react-redux:

npm install --save redux react-redux

关于reactjs - 找不到模块 : Can't resolve 'redux' in node_modules,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55199773/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com