Firebase函数部署报错:暂不支持1代升2代,求回退V1部署方案
Firebase云函数回退到V1及报错解析
报错含义
1. 升级不支持报错
Error: Upgrading from 1st Gen to 2nd Gen is not yet supported. See ...
官方暂不支持将已部署的第一代云函数直接升级到第二代,必须遵循指定迁移流程操作,不能通过直接部署触发升级。
2. URL构造函数报错
Error: 2 UNKNOWN: Getting metadata from plugin failed with error: URL is not a constructor
项目手动安装了低版本url包(0.11.4),但Node.js 18已内置标准URL类,两者冲突导致插件获取元数据失败。
回退到V1云函数的操作步骤
- 降级
firebase-functions版本:第二代函数要求版本≥4.0.0,回退到V1需安装3.x.x稳定版:npm install firebase-functions@3.24.1 --save - 移除冲突依赖:卸载手动安装的
url包,Node.js 18内置该模块无需单独安装:npm uninstall url --save - 确认函数配置:检查
firebase.json,确保functions字段未设置platform: "gcfv2",代码仍使用V1语法(如exports.myFunc = functions.https.onRequest(...))。 - 清理并重新部署:
rm -rf node_modules package-lock.json npm install firebase deploy --only functions
额外提示
Node.js 18将于2025年4月30日停止官方支持,后续建议逐步升级到Node.js 20并按官方流程迁移到第二代云函数,避免后续部署受阻。
内容的提问来源于stack exchange,提问作者Ralph Yozzo
相关产品推荐
相关产品推荐

