首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何解决与NPM的依赖冲突

如何解决与NPM的依赖冲突
EN

Stack Overflow用户
提问于 2022-06-18 00:18:37
回答 2查看 1K关注 0票数 0

我正试图在我的笔记本电脑中安装aws示例演示https://github.com/aws-samples/amazon-chime-sdk-classroom-demo所需的所有npm软件包。但是当我想要运行时,总是得到类似的错误

代码语言:javascript
运行
复制
npm install 

我有点好奇,是不是因为我刚刚得到了我的,所以我得到了错误的npm和节点版本

错误代码显示

代码语言:javascript
运行
复制
npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: @typescript-eslint/eslint-plugin@2.34.0
npm ERR! Found: eslint@8.4.1
npm ERR! node_modules/eslint
npm ERR!   dev eslint@"^8.4.1" from the root project
npm ERR!   peer eslint@"*" from @typescript-eslint/experimental-utils@2.34.0
npm ERR!   node_modules/@typescript-eslint/experimental-utils
npm ERR!     @typescript-eslint/experimental-utils@"2.34.0" from @typescript-eslint/eslint-plugin@2.34.0
npm ERR!     node_modules/@typescript-eslint/eslint-plugin
npm ERR!       dev @typescript-eslint/eslint-plugin@"^2.17.0" from the root project
npm ERR!       1 more (eslint-config-airbnb-typescript)
npm ERR!     @typescript-eslint/experimental-utils@"2.34.0" from @typescript-eslint/parser@2.34.0
npm ERR!     node_modules/@typescript-eslint/parser
npm ERR!       dev @typescript-eslint/parser@"^2.17.0" from the root project
npm ERR!       2 more (@typescript-eslint/eslint-plugin, eslint-config-airbnb-typescript)
npm ERR!     1 more (eslint-plugin-jest)
npm ERR!   7 more (babel-eslint, eslint-config-prettier, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer eslint@"^5.0.0 || ^6.0.0" from @typescript-eslint/eslint-plugin@2.34.0
npm ERR! node_modules/@typescript-eslint/eslint-plugin
npm ERR!   dev @typescript-eslint/eslint-plugin@"^2.17.0" from the root project
npm ERR!   peer @typescript-eslint/eslint-plugin@"^2.7.0" from eslint-config-airbnb-typescript@6.3.2
npm ERR!   node_modules/eslint-config-airbnb-typescript
npm ERR!     dev eslint-config-airbnb-typescript@"^6.3.1" from the root project
npm ERR!     1 more (eslint-config-erb)
npm ERR! 
npm ERR! Conflicting peer dependency: eslint@6.8.0
npm ERR! node_modules/eslint
npm ERR!   peer eslint@"^5.0.0 || ^6.0.0" from @typescript-eslint/eslint-plugin@2.34.0
npm ERR!   node_modules/@typescript-eslint/eslint-plugin
npm ERR!     dev @typescript-eslint/eslint-plugin@"^2.17.0" from the root project
npm ERR!     peer @typescript-eslint/eslint-plugin@"^2.7.0" from eslint-config-airbnb-typescript@6.3.2
npm ERR!     node_modules/eslint-config-airbnb-typescript
npm ERR!       dev eslint-config-airbnb-typescript@"^6.3.1" from the root project
npm ERR!       1 more (eslint-config-erb)
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 /Users/liycheng/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/liycheng/.npm/_logs/2022-06-18T00_11_27_159Z-debug-0.log

我的节点版本和npm版本是:

代码语言:javascript
运行
复制
$ npm -v
8.9.0
$ node -v
v18.2.0

我试图通过以下方式解决依赖冲突

代码语言:javascript
运行
复制
npm install --legacy-peer-deps

但这不起作用

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-06-18 06:41:57

上面提到的项目存储库包含yarn.lock文件,而不包含package-lock.json。更多的是在package.json中定义了许多纱线命令。因此,上述项目是由yarn发起的。因此,您需要使用yarn命令而不是npm

对于第一个检查,您是否在您的计算机上安装了yarn。使用yarn check。如果没有安装,那么使用yarn安装npm install --global yarn。然后使用yarn install --immutable --immutable-cache --check-cache做一个清洁安装。当您使用npm ci时,它是一个类似于npm的命令。

若要了解更多关于纱线检查的信息,请参阅纱线文档

票数 0
EN

Stack Overflow用户

发布于 2022-06-18 00:29:31

演示是使用纱线作为包管理器构建的,因此我建议您使用纱线而不是npm来构建和运行应用程序。

代码语言:javascript
运行
复制
npm install --global yarn
yarn install
yarn start

如果它有效,那么npm安装失败的原因很可能是存储在yarn.lock文件中的一些附加信息,这些信息在使用npm构建时没有进行评估。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72665820

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档