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

升级至Angular 16后无法安装Firebase:npm出现ERESOLVE错误

Angular 16升级后无法安装Firebase的解决方案

问题

Angular从v15升级到v16后,执行npm install firebase @angular/fire时触发依赖冲突错误,具体报错如下:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: morish-wilson@0.0.0
npm ERR! Found: @angular/common@16.0.2
npm ERR! node_modules/@angular/common
npm ERR! @angular/common@"^16.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0" from @angular/fire@7.5.0
npm ERR! node_modules/@angular/fire
npm ERR! @angular/fire@"*" 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/fire@7.5.0版本仅支持Angular 12~15,不兼容Angular 16,导致peer依赖校验失败。

解决办法

1. 安装兼容Angular 16的@angular/fire版本

Angular Fire 7.6.0及以后版本已适配Angular 16,执行以下命令安装最新兼容版本:

npm install firebase @angular/fire@latest

也可以直接指定具体兼容版本:

npm install firebase @angular/fire@7.6.0

2. 临时跳过peer依赖检查(不推荐)

如果暂时无法升级@angular/fire,可使用--legacy-peer-deps参数绕过依赖冲突,但可能引发后续兼容性问题,仅作为临时方案:

npm install firebase @angular/fire --legacy-peer-deps

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.21 03:32:52