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

更新Firebase Functions后遇NPM依赖冲突,无法部署函数

解决Firebase Functions部署的ERESOLVE依赖冲突问题

问题根源

你安装了firebase-functions@4.0.0-rc.0(预发布RC版本),但开发依赖中的firebase-functions-test@0.2.3是旧版本,尽管它的peer依赖标注为>=2.0.0,但实际与4.x版本的firebase-functions存在兼容性冲突,导致npm依赖解析失败。


解决方案

1. 升级firebase-functions-test到兼容版本

旧版本的test工具不支持firebase-functions 4.x,直接升级到最新版即可解决冲突:

npm install firebase-functions-test@latest --save-dev

升级后清理缓存文件并重新安装依赖:

rm -rf node_modules package-lock.json
npm install

2. 降级firebase-functions到稳定版

如果不需要使用RC预发布版本,降级到3.x稳定版可以直接兼容旧的test工具:

npm install firebase-functions@3 --save

同样清理缓存后重新安装:

rm -rf node_modules package-lock.json
npm install

3. 强制部署时使用legacy-peer-deps

如果必须保留当前版本组合,可通过配置让Firebase部署时采用旧的依赖解析规则:

  • 方法一:修改firebase.json,添加预部署命令:
    {
      "functions": {
        "predeploy": ["npm install --legacy-peer-deps"]
      }
    }
    
  • 方法二:部署时直接指定环境变量:
    npm_config_legacy_peer_deps=true firebase deploy --only functions
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.16 03:01:25