try 将react redux软件包安装到我的create react应用程序时出错.我try 过删除和重新安装我的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! 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.

以下是我的软件包中当前依赖项的列表.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博客上一次提到--legacy-peer-deps标志是在他们的npm v7测试版公开时.要了解更多关于国旗的信息,请点击here.

Reactjs相关问答推荐

Firebase删除UserWithEmail AndPassword仅创建匿名用户

是否在Extra Reducer完成作业(job)时触发createListenerMiddleware?

在Reaction中单击并显示子组件延迟/动画

无法在主组件的返回语句中呈现预期组件

如何从Reaction-Arborist树获取排序数据

GitHub页面未正确显示Reaction应用程序网站

带有样式的工具提示导致无法向功能组件提供参考警告

当从子状态更改复制时,react 父状态更改.我该如何防止这种情况?

是否可以直接在 jsx 标签上使用 CSS 定义的 colored颜色 ?

为什么我的 Next.js (React) 组件只有在页面中时才有效?

如何防止开发人员使用 ESLint 在 React 项目中使用特定的钩子?

如何使用样式化函数为 TextField 的输入组件设置样式

改变输入的默认值时出现问题:number react-hook-form

React - 使用 React 显示错误和积极alert

使用dayjs时如何在输入类型日期时间本地字段中设置默认值?

为什么此代码中的 useState 不更新(文本更新但 id 不更新)?

如何根据数据库中的值设置单选按钮选中? - react

如何使用 useEffect 和 if 语句 React

您无权使用阻止 webRequest 侦听器.请务必在 list 中声明 webRequestBlocking 权限

链接的音译 Gatsby JS