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

npm install及Heroku部署时ERESOLVE依赖冲突问题求助

解决Angular依赖冲突(ERESOLVE)问题

错误信息

Installing node modules
       npm ERR! code ERESOLVE
       npm ERR! ERESOLVE could not resolve
       npm ERR! 
       npm ERR! While resolving: @angular-devkit/build-angular@15.0.0
       npm ERR! Found: typescript@4.9.3
       npm ERR! node_modules/typescript
       npm ERR!   dev typescript@"~4.9.3" from the root project
       npm ERR! 
       npm ERR! Could not resolve dependency:
       npm ERR! peer typescript@"~4.8.2" from @angular-devkit/build-angular@15.0.0
       npm ERR! node_modules/@angular-devkit/build-angular
       npm ERR!   dev @angular-devkit/build-angular@"^15.0.0" from the root project
       npm ERR! 
       npm ERR! Conflicting peer dependency: typescript@4.8.4
       npm ERR! node_modules/typescript
       npm ERR!   peer typescript@"~4.8.2" from @angular-devkit/build-angular@15.0.0
       npm ERR!   node_modules/@angular-devkit/build-angular
       npm ERR!     dev @angular-devkit/build-angular@"^15.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.
       npm ERR! 
       npm ERR! See /tmp/npmcache.zQoom/eresolve-report.txt for a full report.
       
       npm ERR! A complete log of this run can be found in:
       npm ERR!     /tmp/npmcache.zQoom/_logs/2022-11-19T21_40_57_670Z-debug-0.log
-----> Build failed

解决方案

方案1:降级TypeScript到兼容版本

  • 打开项目根目录的package.json,找到typescript依赖项,将版本从~4.9.3修改为~4.8.4
  • 执行命令:npm install

方案2:升级Angular构建工具以支持当前TypeScript版本

  • Angular 15.1及以上版本的@angular-devkit/build-angular已支持TypeScript 4.9,执行命令升级:
    npm install @angular-devkit/build-angular@^15.1.0 --save-dev
    
  • 之后执行:npm install

方案3:清理缓存后重新安装

  • 删除本地依赖文件和锁文件:
    • macOS/Linux:rm -rf node_modules package-lock.json
    • Windows:rmdir /s /q node_modules && del package-lock.json
  • 清理npm缓存:npm cache clean --force
  • 重新安装依赖:npm install

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.12 06:31:09