You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Angular 11升级至16遇npm依赖冲突错误求助

Angular 11升级至16时npm依赖冲突问题

我正在将Angular版本从11升级至16,Angular官方文档提供了一定帮助,但仍遇到错误问题。

当前环境版本信息

Angular CLI: 11.2.19
Node: 18.16.0
OS: darwin x64

Angular: 11.2.14
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1102.19
@angular-devkit/build-angular   0.1102.19
@angular-devkit/core            11.2.19
@angular-devkit/schematics      11.2.19
@angular/cli                    11.2.19
@schematics/angular             11.2.19
@schematics/update              0.1102.19
rxjs                            6.6.7
typescript                      4.1.6

执行的升级操作

按照Angular官方文档指引执行了以下命令:

ng update @angular/core@12 @angular/cli@12

遇到的npm安装错误

执行npm i时遇到如下错误:

npm i
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: personal-website@0.0.0
npm ERR! Found: @angular-devkit/build-angular@0.1102.19
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR!   dev @angular-devkit/build-angular@"~16.2.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! dev @angular-devkit/build-angular@"~16.2.0" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: @angular/compiler-cli@16.2.1
npm ERR! node_modules/@angular/compiler-cli
npm ERR!   peer @angular/compiler-cli@"^16.0.0" from @angular-devkit/build-angular@16.2.0
npm ERR!   node_modules/@angular-devkit/build-angular
npm ERR!     dev @angular-devkit/build-angular@"~16.2.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! 
npm ERR! For a full report see:
npm ERR! /Users/micahdittmar/.npm/_logs/2023-08-22T15_51_16_287Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/micahdittmar/.npm/_logs/2023-08-22T15_51_16_287Z-debug-0.log
(base) micahs-air:micah-dittmar micahdittmar$ npm cache clean --force

npm WARN using --force Recommended protections disabled.

补充资源

我找到了一篇相关帖子非常有用,但因发布时间较早且未关联Angular 16,不易被找到,特此补充以帮助他人找到该资源。


内容的提问来源于stack exchange,提问作者Micah

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.12 21:47:27