简体   繁体   English

从 Angular 11 升级到 12 会导致对等依赖冲突

[英]Upgrade from Angular 11 to 12 causes peer dependency conflict

I'm currently upgrading from Angular 11.2.14 to Angular 12.0.5 and I run into the following issue:我目前正在从 Angular 11.2.14升级到 Angular 12.0.5 ,我遇到了以下问题:

npm ERR! Could not resolve dependency:
npm ERR! dev @angular-devkit/build-angular@"12.0.5" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @angular/compiler-cli@12.0.5
npm ERR! node_modules/@angular/compiler-cli
npm ERR!   dev @angular/compiler-cli@"12.0.5" from the root project
npm ERR!   peer @angular/compiler-cli@"^12.0.0" from @angular-devkit/build-angular@12.0.5
npm ERR!   node_modules/@angular-devkit/build-angular
npm ERR!     dev @angular-devkit/build-angular@"12.0.5" from the root project
npm ERR!   2 more (@angular/localize, ng-packagr)
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.

Am I right assuming this is because there is a conflict between the version 12.0.5 and 12.0.0 and they are incompatible?我是否正确假设这是因为版本12.0.512.0.0之间存在冲突并且它们不兼容? All my dependencies have now the same version, why is there a conflict present?我所有的依赖项现在都具有相同的版本,为什么会出现冲突?

package.json包.json

    "@angular-builders/custom-webpack": "12.1.0",
    "@angular-devkit/build-angular": "12.0.5",
    "@angular/animations": "12.0.5",
    "@angular/cdk": "12.0.5",
    "@angular/cli": "12.0.5",
    "@angular/common": "12.0.5",
    "@angular/compiler": "12.0.5",
    "@angular/compiler-cli": "12.0.5",
    "@angular/core": "12.0.5",
    "@angular/flex-layout": "11.0.0-beta.33",
    "@angular/forms": "12.0.5",
    "@angular/language-service": "12.0.5",
    "@angular/material": "11.2.13",
    "@angular/platform-browser": "12.0.5",
    "@angular/platform-browser-dynamic": "12.0.5",
    "@angular/router": "12.0.5",

Thanks a lot!非常感谢!

I had to use npm v6 to make a successful update:我必须使用 npm v6 才能成功更新:

npm -g i npm@^6
npm i
ng update @angular/cli@^12 @angular/core@^12

I'm currently upgrading from Angular 11.2.14 to Angular 12.0.5 and I run into the following issue:我目前正在从 Angular 11.2.14升级到 Angular 12.0.5 ,但遇到了以下问题:

npm ERR! Could not resolve dependency:
npm ERR! dev @angular-devkit/build-angular@"12.0.5" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @angular/compiler-cli@12.0.5
npm ERR! node_modules/@angular/compiler-cli
npm ERR!   dev @angular/compiler-cli@"12.0.5" from the root project
npm ERR!   peer @angular/compiler-cli@"^12.0.0" from @angular-devkit/build-angular@12.0.5
npm ERR!   node_modules/@angular-devkit/build-angular
npm ERR!     dev @angular-devkit/build-angular@"12.0.5" from the root project
npm ERR!   2 more (@angular/localize, ng-packagr)
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.

Am I right assuming this is because there is a conflict between the version 12.0.5 and 12.0.0 and they are incompatible?我假设这是因为版本12.0.512.0.0之间存在冲突并且它们不兼容,我是否正确? All my dependencies have now the same version, why is there a conflict present?我所有的依赖项现在都具有相同的版本,为什么会出现冲突?

package.json包.json

    "@angular-builders/custom-webpack": "12.1.0",
    "@angular-devkit/build-angular": "12.0.5",
    "@angular/animations": "12.0.5",
    "@angular/cdk": "12.0.5",
    "@angular/cli": "12.0.5",
    "@angular/common": "12.0.5",
    "@angular/compiler": "12.0.5",
    "@angular/compiler-cli": "12.0.5",
    "@angular/core": "12.0.5",
    "@angular/flex-layout": "11.0.0-beta.33",
    "@angular/forms": "12.0.5",
    "@angular/language-service": "12.0.5",
    "@angular/material": "11.2.13",
    "@angular/platform-browser": "12.0.5",
    "@angular/platform-browser-dynamic": "12.0.5",
    "@angular/router": "12.0.5",

Thanks a lot!非常感谢!

I had got same error on every version angular update when i used official update guide https://update.angular.io/ and command npx @angular/cli@12 update @angular/core@12 @angular/cli@12.当我使用官方更新指南https://update.angular.io/和命令 npx @angular/cli@12 update @angular/core@12 @angular/cli@12 时,我在每个版本的角度更新上都有同样的错误。 After long googling and trying i found next way for angular and angular material update (example for 10 to 11 update):经过长时间的谷歌搜索和尝试,我找到了下一种角度和角度材料更新的方法(例如 10 到 11 更新):

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

getting subj error获取主题错误

remove node_modules and package-lock.json删除 node_modules 和 package-lock.json

npm install

Git commit Git提交

ng update @angular/core@11 --migrate-only --from 10 --to 11

Git commit Git提交

ng update @angular/cli@11 --migrate-only --from 10 --to 11

Git commit Git提交

npx @angular/cli@11 update @angular/material@11 @angular/flex-layout@11.0.0-beta.33

更新您的 tsconfig.json,然后运行 ​​sudo npm install --force

Downgrad npm v6, I tried bunch of commands after googling get successful now降级 npm v6,我在谷歌搜索成功后尝试了一堆命令

npm -g i npm@^6
npm i
ng update @angular/cli@^12 @angular/core@^12

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

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