Node.js 尝试安装react-redux依赖项时出错
尝试将react-redux包安装到我的create react-app应用程序时出错。我已尝试删除并重新安装我的node_modules文件夹,并使用管理员权限进行安装,但仍然收到相同的错误Node.js 尝试安装react-redux依赖项时出错,node.js,reactjs,npm,react-redux,Node.js,Reactjs,Npm,React Redux,尝试将react-redux包安装到我的create react-app应用程序时出错。我已尝试删除并重新安装我的node_modules文件夹,并使用管理员权限进行安装,但仍然收到相同的错误 ➜ frontend git:(main) ✗ npm i react-redux npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree 下面是控制台的剩余输出 npm ERR! npm ERR! Whi
➜ frontend git:(main) ✗ npm i react-redux
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
下面是控制台的剩余输出
npm ERR!
npm ERR! While resolving: frontend@0.1.0
npm ERR! Found: react@17.0.1
npm ERR! node_modules/react
npm ERR! react@"^17.0.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.3" from react-redux@7.2.1
npm ERR! node_modules/react-redux
npm ERR! react-redux@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
下面是my package.json中当前依赖项的列表
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"axios": "^0.21.0",
"react": "^17.0.1",
"react-bootstrap": "^1.4.0",
"react-dom": "^17.0.1",
"react-router-bootstrap": "^0.25.0",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.4",
"redux": "^4.0.5",
"redux-devtools-extension": "^2.13.8",
"redux-thunk": "^2.3.0",
"tachyons": "^4.12.0"
},
看起来您正在使用最新的npm版本(v7)。 正如日志中提到的,尝试使用
npm安装--旧式对等dep
npm博客上一次提到
--遗留对等deps
标志是在他们的npm v7测试版公开时。要了解更多有关标志的信息,请转到。尝试安装推荐的nodejs版本(下面的屏幕截图)。这应该可以解决这个问题
以下是此错误及其解决方案的重现(以下截图):
问题:
Nodejs:最新功能:
解决方案:
Nodejs:建议大多数用户使用:
安装推荐版本的node js立即修复了此问题,允许安装相关依赖项
如果您在react本机依赖项中遇到此问题,则安装推荐版本后,请确保更新pod文件。尝试使用Node.js最新的“推荐给大多数用户”版本。
它对我有效在Mac上尝试过,它有效。。按照升级到最新LTS的步骤进行操作
n[版本号]尝试将其与纱线一起添加。为我工作双向 1-npm安装yourPakcge--旧式对等DEP 2-建议大多数节点版本的用户安装
安装推荐版本的节点的更好方法。因为它适用于所有软件包。尝试安装另一个npm软件包时,出现类似错误。使用选项
--遗留对等DEP安装解决了这些问题。