9

我正在尝试将我的项目中的 Angular 从版本 10.2 更新到 11.0。运行 ng 更新:

  @angular-devkit/build-angular      0.1002.0 -> 0.1100.1     ng update @angular-devkit/build-angular
  @angular/cdk                       10.2.7 -> 11.0.0         ng update @angular/cdk
  @angular/cli                       10.2.0 -> 11.0.1         ng update @angular/cli
  @angular/core                      10.2.3 -> 11.0.0         ng update @angular/core
  @angular/material                  10.2.7 -> 11.0.0         ng update @angular/material

不幸的是,我尝试更新的每个软件包都失败了。我尝试了 --force 和 --allowDirty 标志。

@角cli

npm ERR! Found: @angular-devkit/build-angular@0.1002.0
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR!   dev @angular-devkit/build-angular@"~0.1100.1" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! dev @angular-devkit/build-angular@"~0.1100.1" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: @angular/compiler-cli@11.0.0
npm ERR! node_modules/@angular/compiler-cli
npm ERR!   peer @angular/compiler-cli@"^11.0.0 || ^11.0.0-next" from @angular-devkit/build- 
angular@0.1100.1
npm ERR!   node_modules/@angular-devkit/build-angular
npm ERR!     dev @angular-devkit/build-angular@"~0.1100.1" from the root project

@angular-devkit/build-angular

npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! Found: @angular-devkit/build-angular@0.1002.0
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR!   dev @angular-devkit/build-angular@"~0.1100.1" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! dev @angular-devkit/build-angular@"~0.1100.1" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: @angular/compiler-cli@11.0.0
npm ERR! node_modules/@angular/compiler-cli
npm ERR!   peer @angular/compiler-cli@"^11.0.0 || ^11.0.0-next" from @angular-devkit/build-angular@0.1100.1
npm ERR!   node_modules/@angular-devkit/build-angular
npm ERR!     dev @angular-devkit/build-angular@"~0.1100.1" from the root project

@角/材料

Installing packages (npm)...npm ERR! code ERESOLVE
npm ERR! Cannot read property 'length' of undefined

@角/cdk

Found: @angular-devkit/build-angular@0.1002.0
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR!   dev @angular-devkit/build-angular@"~0.1100.1" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! dev @angular-devkit/build-angular@"~0.1100.1" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: @angular/compiler-cli@11.0.0
npm ERR! node_modules/@angular/compiler-cli
npm ERR!   peer @angular/compiler-cli@"^11.0.0 || ^11.0.0-next" from @angular-devkit/build- 
angular@0.1100.1
npm ERR!   node_modules/@angular-devkit/build-angular
npm ERR!     dev @angular-devkit/build-angular@"~0.1100.1" from the root project

更新按特定顺序安装后,我设法更新,但现在 NPM 不会安装,并给出以下消息:

Found: @angular-devkit/build-angular@0.1002.0
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR!   dev @angular-devkit/build-angular@"~0.1100.1" from the root 
project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! dev @angular-devkit/build-angular@"~0.1100.1" from the root 
project
npm ERR! 
npm ERR! Conflicting peer dependency: @angular/compiler-cli@11.0.0
npm ERR! node_modules/@angular/compiler-cli
npm ERR!   peer @angular/compiler-cli@"^11.0.0 || ^11.0.0-next" from 
@angular-devkit/build-angular@0.1100.1
npm ERR!   node_modules/@angular-devkit/build-angular
npm ERR!     dev @angular-devkit/build-angular@"~0.1100.1" from the 
root project
4

5 回答 5

5

我遇到了完全相同的问题,尝试了不同的升级顺序,多次删除了 node_modules 文件夹,但仍然没有运气。对我来说,问题在于我使用的是 Node v15。我卸载了它并重新安装了 Node v14 -> 工作

于 2020-11-14T18:02:46.980 回答
4

有同样的问题。对我来说,问题是代码编辑器是打开的,

关闭编辑器并运行ng update @angular/core @angular/cli角度成功更新

于 2020-11-16T15:58:10.137 回答
1

就我而言

  • 删除 node_modules 和 package-lock.json
  • npm 缓存清理 --force
  • npm i --force

我认为问题是在节点升级到 v14 之后

于 2021-05-22T13:00:41.350 回答
1

我遇到了同样的问题,只需删除 node_modules、package-lock.json 并运行 npm install,现在一切正常!

于 2020-11-27T13:26:20.297 回答
0

我有同样的问题,我最终使用了纱线包管理器,它解决了这个问题。

于 2020-11-14T10:21:08.190 回答