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

Angular依赖树解析失败求助:创建首个项目遇ERESOLVE错误

Angular项目创建时ERESOLVE依赖冲突解决

完成Node.js和Angular安装后,创建第一个项目时遇到如下依赖树解析错误:

54 error code ERESOLVE
55 error ERESOLVE unable to resolve dependency tree
56 error
57 error While resolving: hello-world2@0.0.0
57 error Found: @angular/core@15.1.3
57 error node_modules/@angular/core
57 error   @angular/core@"^15.1.0" from the root project
57 error
57 error Could not resolve dependency:
57 error peer @angular/core@"15.1.4" from @angular/animations@15.1.4
57 error node_modules/@angular/animations
57 error   @angular/animations@"^15.1.0" from the root project
57 error
57 error Fix the upstream dependency conflict, or retry
57 error this command with --force or --legacy-peer-deps
57 error to accept an incorrect (and potentially broken) dependency resolution.
58 error
58 error
58 error For a full report see:
58 error C:\Users\vule2\AppData\Local\npm-cache\_logs\2023-02-08T18_19_54_573Z-eresolve-report.txt

解决方法

  • 方案1:创建项目时添加--legacy-peer-deps参数(新手首选)
    直接用以下命令创建项目,跳过严格的peer依赖版本检查:

    ng new hello-world2 --legacy-peer-deps
    
  • 方案2:更新Angular CLI到匹配版本

    1. 查看当前CLI版本:
      ng version
      
    2. 如果CLI版本不是15.1.4,全局更新:
      npm install -g @angular/cli@15.1.4
      
    3. 重新创建项目,此时生成的依赖版本会自动匹配。
  • 方案3:手动调整已创建项目的依赖版本
    如果已经创建了项目,打开项目根目录的package.json文件,将@angular/core的版本修改为"^15.1.4",保存后运行:

    npm install
    

内容的提问来源于stack exchange,提问作者Vukašin

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.01 03:15:27