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

Angular 14中安装Nebular主题出现依赖冲突问题求助

解决npm ERESOLVE依赖树解析错误(Angular与Nebular版本冲突)

错误核心

你的项目存在版本依赖冲突:

  • 根项目依赖@angular/animations@^14.2.0,当前安装版本为14.2.5
  • 依赖的@nebular/theme@9.1.0-rc.6要求peer依赖@angular/animations@^13.0.0,两者版本不匹配导致npm无法解析依赖树。

解决方案

1. 升级Nebular到兼容Angular 14的版本

@nebular/theme 9.x系列仅支持Angular 13,需升级到支持Angular 14的版本(10.x及以上):

npm install @nebular/theme@latest --save

若需指定稳定兼容版本,可执行:

npm install @nebular/theme@10.0.0 --save

2. 降级Angular到13.x版本

若暂时无法升级Nebular,可将Angular核心依赖统一降级到13.x版本以匹配Nebular的要求:

npm install @angular/animations@^13.0.0 @angular/core@^13.0.0 @angular/common@^13.0.0 @angular/compiler@^13.0.0 @angular/platform-browser@^13.0.0 @angular/platform-browser-dynamic@^13.0.0 --save

确保所有Angular核心包版本一致,避免新增冲突。

3. 临时跳过peer依赖检查(仅开发环境建议)

如果只是临时需要完成依赖安装,可使用npm参数强制忽略冲突:

  • 使用--legacy-peer-deps(恢复npm v6的peer依赖处理逻辑,相对安全):
npm install --legacy-peer-deps
  • 或使用--force(强制接受可能失效的依赖解析结果):
npm install --force

⚠️ 注意:这两种方式可能引发运行时兼容性问题,生产环境禁止使用。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.17 05:25:23