繁体   English   中英

节点 V18 的冲突对等依赖错误

[英]Conflicting peer dependency Error with Node V18

有谁知道这个错误是什么? 我只是尝试安装任何依赖项,这几天总是弹出。 我不知道发生了什么事。

npm ERR!       1 more (the root project)
npm ERR!     peer @angular/platform-browser@"13.2.4" from @angular/platform-browser-dynamic@13.2.4
npm ERR!     node_modules/@angular/platform-browser-dynamic
npm ERR!       peer @angular/platform-browser-dynamic@">=10.0.0" from jest-preset-angular@11.1.1
npm ERR!       node_modules/jest-preset-angular
npm ERR!         dev jest-preset-angular@"11.1.1" from the root project
npm ERR!       1 more (the root project)
npm ERR!     2 more (@angular/router, the root project)
npm ERR!   7 more (@angular/platform-browser-dynamic, @angular/router, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^6.0.0 || ^7.0.0 || ^8.0.0" from @agm/core@1.1.0
npm ERR! node_modules/@agm/core
npm ERR!   @agm/core@"^1.1.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @angular/common@8.2.14
npm ERR! node_modules/@angular/common
npm ERR!   peer @angular/common@"^6.0.0 || ^7.0.0 || ^8.0.0" from @agm/core@1.1.0
npm ERR!   node_modules/@agm/core
npm ERR!     @agm/core@"^1.1.0" 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 XXXXXXX\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:

我真的很感谢你的帮助

@agm/core无人维护,自 2020 年 7 月以来未更新。

你有两种可能性:

  • 通过使用--force强制安装并测试它是否仍然有效来试试你的运气。
  • 选择另一个仍在维护的库。

如果您从以前的节点版本切换到 node18,请首先清理您的环境。

rm -rf node_modules
rm package-lock.json // or yarn.lock if you are using yarn
npm cache verify
npm i

如果错误仍然存在,则说明您使用的某些模块或某些节点模块的依赖项与 node18 不兼容。

在这种情况下,您可以分析错误来自何处并尝试不同的版本。 但这通常会让您遇到其他问题,例如旧版本或过时的版本。

一个好的但耗时的方法是:

  1. 创建一个新的空 Angular 项目。 它将正确安装所有需要和工作的 Angular 模块。

  2. 将您的代码从旧项目移到新项目中,没有 package.json

  3. 重新安装所有没有版本的节点模块。 如果出现错误,请记住该模块。

  4. 如果某些模块发生错误,研究是否存在已知问题。

  5. 如果似乎没有解决方案(应该只是旧的而不是更新的模块),请查看如何替换它们。

  6. 很有可能在较新的模块中,有破坏性的变化,你的代码将不会被执行。 (例如,方法名称已更改,方法已删除)

升级到新的节点版本有时真的很有压力。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM