Firebase Functions V2部署时如何保留函数名中的短横线?
Firebase Functions V2 带短横线函数名的部署方法
问题重现
你定义了带短横线的V2版本函数:
exports["processing-file-finished"] = functions.database.onValueWritten( { instance: this.app.realtimeDatabase, ref: "/processing/{fileId}/finished", }, myModule.handleFinish )
执行部署命令时:
firebase deploy --only functions:processing-file-finished
或
firebase deploy --only functions:processing.file.finished
均收到错误提示:
Function 'processing.file.finished' is not defined in the provided module.
解决方法
问题出在shell会把短横线(-)识别为命令参数的分隔符,导致Firebase CLI无法正确解析带短横线的函数名。只需用引号将函数名部分完整包裹,让shell把整个函数名当作一个整体传递给CLI即可。
正确的部署命令如下:
firebase deploy --only "functions:processing-file-finished"
也可以使用单引号(适配bash、zsh等主流shell):
firebase deploy --only 'functions:processing-file-finished'
执行上述命令后,CLI就能正确识别带短横线的函数名,完成部署。
内容的提问来源于stack exchange,提问作者BąQ
相关产品推荐
相关产品推荐

