【问题标题】:How do you read npm audit ERESOLVE error?您如何阅读 npm audit ERESOLVE 错误?
【发布时间】:2021-09-13 22:15:58
【问题描述】:

我经常收到类似于下面的错误 ERESOLVE。你是怎么读的?

>npm audit fix
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: myapp@0.0.0
npm ERR! Found: @angular/compiler@12.1.0
npm ERR! node_modules/@angular/compiler
npm ERR!   @angular/compiler@"12.1.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/compiler@"12.1.1" from @angular/compiler-cli@12.1.1
npm ERR! node_modules/@angular/compiler-cli
npm ERR!   dev @angular/compiler-cli@"^12.1.0" from the root project
npm ERR!   peer @angular/compiler-cli@"^12.0.0 || ^12.1.0-next" from @angular-devkit/build-angular@12.1.0
npm ERR!   node_modules/@angular-devkit/build-angular
npm ERR!     dev @angular-devkit/build-angular@"12.1.0" from the root project

您如何阅读它 - 哪个包取决于哪个?我可以控制树的哪一端?顶部还是底部?

我是否在我的应用程序中添加了 @angular-devkit/build-angular 并且它需要但找不到 angular/compiler ?还是相反?

【问题讨论】:

  • 您似乎遇到了依赖冲突(不正确且可能损坏的依赖)问题,尝试使用--force--legacy-peer-deps 运行命令,例如:npm audit fix --force。如果不生效,临时解决办法是使用节点的旧版本(降级节点版本),因为它有时会导致发生此类错误。参考:Unable to resolve dependency tree error when installing npm packages.
  • 这不是我真正需要的。我编辑了问题..

标签: node.js angular asp.net-core npm


【解决方案1】:

我可能是错的,但这是我读到的:

哪个包取决于哪个?

您的应用直接依赖于:

  • @angular/compiler@"12.1.0"
  • @angular/compiler-cli@"^12.1.0"
  • @angular-devkit/build-angular@"12.1.0"

您的应用传递依赖于:

  • @angular/compiler@"12.1.1" 来自 @angular/compiler-cli@12.1.1 @angular/compiler-cli 版本。
  • @angular/compiler-cli@"^12.0.0 || ^12.1.0-next" 来自 @angular-devkit/build-angular@12.1.0 @angular-devkit/build-angular 版本。

所以我读到的是存在冲突,因为您的应用程序直接依赖于 @angular/compiler@"12.1.0" 并传递地依赖于 @angular/compiler@"12.1.1"(来自 @angular/compiler-cli@12.1.1) 您可以通过添加看起来像缺少插入符号的东西来解决这个问题,即@angular/compiler@"^12.1.0"

不相关的^,我遇到了类似的问题,但所有版本都兼容。我删除了package-lock.jsonnode_modules 并再次安装它们,它工作正常。

【讨论】:

    【解决方案2】:

    我已使用以下命令修复它:

    1. rm package-lock.json
    2. rm -rf 节点模块
    3. 纱线安装
    4. npm 我

    【讨论】:

      猜你喜欢
      • 2023-01-04
      • 2022-10-07
      • 2014-03-27
      • 2022-06-23
      • 2021-07-02
      • 1970-01-01
      • 2021-04-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多