【问题标题】:Unable to update Angular from 10 to 11 due to dependency errors由于依赖错误,无法将 Angular 从 10 更新到 11
【发布时间】:2022-01-25 05:41:04
【问题描述】:

我正在关注site 并尝试通过以下命令将我的项目更新到 11.0。

npx @angular/cli@11 update @angular/core@11 @angular/cli@11

每次我运行它,它都会给我以下错误:

npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: my-first-app@0.0.0
npm ERR! Found: @angular-devkit/build-angular@0.1002.4
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR!   dev @angular-devkit/build-angular@"~0.1102.17" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! dev @angular-devkit/build-angular@"~0.1102.17" from the root project
npm ERR! Conflicting peer dependency: @angular/compiler-cli@11.2.14
npm ERR! node_modules/@angular/compiler-cli
npm ERR!   peer @angular/compiler-cli@"^11.0.0 || ^11.2.0-next" from @angular-devkit/build-angular@0.1102.17
npm ERR!   node_modules/@angular-devkit/build-angular
npm ERR!     dev @angular-devkit/build-angular@"~0.1102.17" from the root project
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 install --legacy-peer-deps

我不确定上述命令有什么帮助,因为我已经运行了 npm install 并且现在只是尝试使用 npx @angular/cli@11 update @angular/core@11 @angular/cli@11

进行升级

环境详情:

Global Angular CLI: 13.1.2
Local Angular CLI: 10.2.4
Angular version: 10.2.5
Node: 16.13.1

我可以做些什么来让它发挥作用?

【问题讨论】:

  • 在更新命令后添加--force
  • @R.Richards --force 没有帮助。

标签: angular npm-install angular10 angular-upgrade npm-update


【解决方案1】:

我有同样的问题,所以在package.json中更改了一些依赖版本

"dependencies": {
  "@angular/animations": "^11.2.14",
  "@angular/cdk": "11.0.4",
  "@angular/common": "^11.2.14",
  "@angular/compiler": "^11.2.14",
  "@angular/core": "^11.2.14",
  "@angular/forms": "^11.2.14",
  "@angular/platform-browser": "^11.2.14",
  "@angular/platform-browser-dynamic": "^11.2.14",
  "@angular/router": "^11.2.14",
}

"devDependencies": {
  "@angular-devkit/build-angular": "^0.1102.6",
  "@angular/cli": "^11.2.17",
  "@angular/compiler-cli": "^11.2.14",
  "@angular/language-service": "11.2.14"
}

删除 node_modules 并再次运行 npm i

【讨论】:

    【解决方案2】:

    1- 转到Nodejs 网站并将您的版本更新到最新的 LTS 版本。

    2- 转到您的操作系统命令行并运行 npm i -g npm 以将您的 npm 更新到最新版本。

    3- 再次通过 npm uninstallnpm install 将您的全局 Angular 版本更新到 v11.0,

    4- 如果这些都不起作用,请尝试在另一台计算机上更新。

    【讨论】:

      猜你喜欢
      • 2018-11-04
      • 1970-01-01
      • 2021-01-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-13
      相关资源
      最近更新 更多