安装Firebase的Algolia扩展时遇nodejs22与GCF Gen1不兼容错误
解决Firebase安装Algolia扩展时的GCF Gen1运行时错误
错误原因
GCF第一代云函数不支持Node.js 22运行时,扩展默认尝试用Node.js22创建Gen1函数,触发运行时验证失败。
解决方案
1. 指定兼容的Node.js版本(保留Gen1函数)
- CLI安装时,通过参数指定运行时为
nodejs20(Gen1支持的最高稳定版本):firebase ext install algolia/firestore-algolia-search --params=RUNTIME=nodejs20 - 控制台安装时,进入扩展高级配置选项,找到运行时版本设置,切换为
nodejs20后重试安装。
2. 切换到GCF第二代函数(推荐)
GCF Gen2支持Node.js22及更高版本,性能和扩展性更优:
- CLI安装时添加参数指定函数世代:
firebase ext install algolia/firestore-algolia-search --params=FUNCTION_GEN=2 - 控制台安装时,在扩展配置的高级选项中选择第二代函数世代,再完成安装。
3. 清理残留资源后重试
若之前安装失败残留了部分资源,先卸载扩展清理:
firebase ext uninstall algolia/firestore-algolia-search
再按照上述修改后的配置重新安装。
错误详情
RESOURCE_ERROR at /deployments/firebase-ext-firestore-algolia-search-claims/resources/executeFullIndexOperation: {"ResourceType":"gcp-types/cloudfunctions-v1:projects.locations.functions","ResourceErrorCode":"400","ResourceErrorMessage":{"code":400,"message":"创建第一代函数projects/zayyanestate/locations/us-central1/functions/ext-firestore-algolia-search-claims-executeFullIndexOperation失败:运行时验证错误:[error_code: INVALID_RUNTIME\nmessage: \"GCF Gen1不支持nodejs22运行时\"\n]","status":"INVALID_ARGUMENT","statusMessage":"Bad Request","requestPath":"https://cloudfunctions.googleapis.com/v1/projects/zayyanestate/locations/us-central1/functions","httpMethod":"POST"}}; RESOURCE_ERROR at /deployments/firebase-ext-firestore-algolia-search-claims/resources/executeIndexOperation: {"ResourceType":"gcp-types/cloudfunctions-v1:projects.locations.functions","ResourceErrorCode":"400","ResourceErrorMessage":{"code":400,"message":"创建第一代函数projects/zayyanestate/locations/us-central1/functions/ext-firestore-algolia-search-claims-executeIndexOperation失败:运行时验证错误:[error_code: INVALID_RUNTIME\nmessage: \"GCF Gen1不支持nodejs22运行时\"\n]","status":"INVALID_ARGUMENT","statusMessage":"Bad Request","requestPath":"https://cloudfunctions.googleapis.com/v1/projects/zayyanestate/locations/us-central1/functions","httpMethod":"POST"}}
内容的提问来源于stack exchange,提问作者Saw Tha Wah
相关产品推荐
相关产品推荐

