javascript - 如何解决这个 npm install 依赖问题?
问题描述
我正在尝试添加npm install react-material-ui-carousel --save
到我的反应项目中。但是,当我尝试安装时,我得到了这个依赖树问题。
- 我已经删除了 lock 和 npm 模块文件,然后
npm install
是整个项目。然而,下面仍然出现同样的错误。
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: buckets@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! peer react@"^16.8.0 || ^17.0.0" from @material-ui/core@4.11.3
npm ERR! node_modules/@material-ui/core
npm ERR! @material-ui/core@"^4.11.2" from the root project
npm ERR! peer @material-ui/core@"^4.9.11" from react-material-ui-carousel@2.2.1
npm ERR! node_modules/react-material-ui-carousel
npm ERR! react-material-ui-carousel@"*" from the root project
npm ERR! 1 more (@material-ui/icons)
npm ERR! 2 more (react-dom, @material-ui/icons)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.13.1" from react-material-ui-carousel@2.2.1
npm ERR! node_modules/react-material-ui-carousel
npm ERR! react-material-ui-carousel@"*" 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.
npm ERR!
npm ERR! See /home/user/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/user/.npm/_logs/2021-03-02T19_57_57_671Z-debug.log
我的其他依赖项:
{
"name": "app",
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^4.11.2",
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.57",
"@reduxjs/toolkit": "^1.5.0",
"@testing-library/jest-dom": "^5.11.6",
"@testing-library/react": "^11.2.2",
"@testing-library/user-event": "^12.6.0",
"axios": "^0.21.1",
"chartist": "^0.10.1",
"react": "^17.0.1",
"react-chartist": "^0.14.4",
"react-dom": "^17.0.1",
"react-hook-form": "^6.14.2",
"react-redux": "^7.2.2",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.1",
"react-window": "^1.8.6",
"redux": "^4.0.5",
"redux-persist": "^6.0.0",
"web-vitals": "^0.2.4"
},
我可以尝试的另一个选项是 --legacy-peer-deps
,但如果没有其他方法,我只会将其作为最后一个结果选项。
如何正确修复依赖树错误react-material-ui-carousel
以安装在我的项目中?
解决方案
在命令末尾添加--force
或。--legacy-peer-deps
像这样:npm install react-material-ui-carousel --save --legacy-peer-deps
推荐阅读
- coldfusion - 如何使用冷融合从 IMAP 获取所有内联图像 CID 值?
- android-activity - 片段和活动生命周期之间的关系
- typescript - 是否可以在子文件夹中运行他的打字稿编译器?
- sqlite - 如何根据用户不在设备上检索数据
- javascript - req.body 中的 JSON 数据数组
- rest - 在后端提供动态文件的最佳实践
- java - 使用 Java 8,如何在列表中为 obj[4] 设置字符串常量
- java - 将 AspectJ @DeclareParents defaultImpl 代码用作依赖项时不使用
- vb.net - VB.NET - 有没有办法以编程方式创建调度程序只是为了调用某个 url/api?
- sql - 条件是在 oracle sql 中 allotment_date-present 日期之间的天数大于 91 天