尝试安装 react

编程入门 行业动态 更新时间:2024-10-17 11:32:10
本文介绍了尝试安装 react-redux 依赖项时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在尝试将 react-redux 包安装到我的 create-react-app 应用程序时遇到错误.我尝试删除并重新安装我的 node_modules 文件夹以及使用管理员权限安装它,但我仍然收到相同的错误

I am getting an error trying to install the react-redux package onto my create-react-app application. I have tried deleting and reinstalling my node_modules folder as well as installing it with admin permissions and I am still receiving the same error

➜ 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.

这是我的 package.json 中当前依赖项的列表

Here is the list of current dependencies in 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 install --legacy-peer-deps

It looks like you are using the latest npm version (v7). As mention in the logs, try with npm install --legacy-peer-deps

npm 博客上一次提到 --legacy-peer-deps 标志是在他们的 npm v7 测试版公开时.要阅读有关该标志的更多信息,请转到这里.

The last time npm Blog mentioned the --legacy-peer-deps flag was while their beta version of npm v7 got public. To read more about the flag go here.

更多推荐

尝试安装 react

本文发布于:2023-11-24 02:13:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1623592.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:react

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!