Angular 17初始化项目遇ERESOLVE依赖冲突错误及解决方法
Angular 17 新项目npm ERESOLVE依赖冲突解决方案
初始化Angular 17新项目时触发如下npm依赖解析错误:
npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: project-v2@0.0.0 npm ERR! Found: @angular/core@17.0.0 npm ERR! node_modules/@angular/core npm ERR! @angular/core@"^17.0.0" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer @angular/core@"17.0.1" from @angular/animations@17.0.1 npm ERR! node_modules/@angular/animations npm ERR! @angular/animations@"^17.0.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.
问题原因
@angular/animations@17.0.1的peer依赖要求为@angular/core@17.0.1,但当前环境中仅存在@angular/core@17.0.0,且17.0.1版本暂未正式发布,导致依赖树无法正常解析。
解决步骤
- 安装与
@angular/core@17.0.0匹配的@angular/animations版本:npm install @angular/animations@17.0.0 - 确保
@angular/core版本锁定为17.0.0:npm install @angular/core@17.0.0 - 运行Angular更新命令同步所有依赖:
ng update
内容的提问来源于stack exchange,提问作者bassaoudm
相关产品推荐
相关产品推荐

