gpt4 book ai didi

npm - 如何阅读 npm "conflicting peer dependency"错误消息?

转载 作者:行者123 更新时间:2023-12-04 11:13:00 25 4
gpt4 key购买 nike

我正在尝试升级我拥有的项目的一些 npm 依赖项,但出现“冲突的对等依赖项”错误。
我在这个网站上看到很多问题,寻求帮助修复此类错误。但是,我一直在努力寻找有关这些错误实际含义的信息。我觉得如果我理解了这一点,我就有机会自己弄清楚如何解决问题。
这是我试图解释的错误消息:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: @angular-devkit/build-angular@0.1102.5
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR! dev @angular-devkit/build-angular@"~0.1102.9" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! dev @angular-devkit/build-angular@"~0.1102.9" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @angular/localize@11.2.10
npm ERR! node_modules/@angular/localize
npm ERR! peerOptional @angular/localize@"^11.0.0 || ^11.2.0-next" from @angular-devkit/build-angular@0.1102.9
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR! dev @angular-devkit/build-angular@"~0.1102.9" 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 install 重现。在 this Github branch 的根目录中(我正在使用 npm 7.10.0 。)
我对“冲突的对等依赖项”错误的一般理解是我依赖的某些包正在表达 peer dependency在与我实际安装的软件包版本不匹配的软件包版本规范上。
例如,如果我的项目直接依赖于包 AB ,我有版本 12.0.0A已安装,但我的版本 B^11.0.0 具有对等依赖性包 A ,那么我会得到一个冲突的对等依赖错误,因为我使用的是 B带有 A 的版本它可能不兼容。
因此,对于此错误消息可能意味着什么,我最好的猜测是我依赖的某些包对 @angular/localize 具有对等依赖关系。版本规范 ^11.0.0 || ^11.2.0-next ,但此规范与 @angular/localize 的版本不匹配我已经安装了。
当我看 my package-lock.json ,我确实看到了 node_modules/@angular-devkit/build-angular条目有条目 "@angular/localize": "^11.0.0 || ^11.2.0-next"在其 peerDependencies .
然而,这是唯一提到的 @angular/localize此文件中的任何位置 -- 或者确实在 package.json 中.我没有明确要求安装它。此外,它被标记为 "optional": truepeerDependenciesMetanode_modules/@angular-devkit/build-angular .所以看到与它相关的错误消息是令人惊讶的。
该错误提到特定的冲突对等依赖项是 @angular/localize@11.2.10 .我看不出那个版本号是从哪里来的。但无论如何,它实际上似乎符合下面的依赖规范:如果我去 semver.npmjs.com并输入 @angular/localize作为包和 ^11.0.0 || ^11.2.0-next作为版本范围,我看到版本 11.2.10以绿色突出显示的包,表明它匹配范围。
所以我真的很感谢一些帮助详细了解此错误消息告诉我的内容。不知道为什么 npm正在尝试安装 11.2.10@angular/localize ,或者为什么它认为这与 @angular-devkit/build-angular 的对等依赖规范冲突.感觉我可能完全误解了这条消息。
我猜这归结为某些 Angular 软件包的最新发布版本之间存在某种不兼容。如果有人对如何修复此特定错误有任何指示,那就太好了——但我对简单地了解错误消息告诉我的内容更感兴趣,因此我可以自己解决。
提前谢谢了!

最佳答案

通读 this GitHub issue ,看来我对错误消息的解释是正确的,这实际上是 npm 中的一个错误。 .
这似乎已报告为 npm/cli/issues/3083 ;修复 has been merged ,所以我想我们只需要等到它被包含在一些即将推出的 npm 中。释放。

关于npm - 如何阅读 npm "conflicting peer dependency"错误消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67185714/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com