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

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版本暂未正式发布,导致依赖树无法正常解析。

解决步骤

  1. 安装与@angular/core@17.0.0匹配的@angular/animations版本:
    npm install @angular/animations@17.0.0
    
  2. 确保@angular/core版本锁定为17.0.0:
    npm install @angular/core@17.0.0
    
  3. 运行Angular更新命令同步所有依赖:
    ng update
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.06 16:32:22