节点8 Firebase功能无法从CloudBuild部署

节点8 Firebase功能无法从CloudBuild部署,firebase,google-cloud-functions,google-cloud-build,Firebase,Google Cloud Functions,Google Cloud Build,我有一个项目,它使用Node 8引擎成功地从本地开发环境部署到firebase。我一直试图让它与CloudBuild一起工作,但是,由于使用async关键字,我遇到了一个语法错误: /workspace/functions/lib/index.js:13 Step #5: app.get('XXXXXXXXX', async (req, resp) => { Step #5: ^ Step #5: Step #5: SyntaxError: Unexpected token ( Step

我有一个项目,它使用Node 8引擎成功地从本地开发环境部署到firebase。我一直试图让它与CloudBuild一起工作,但是,由于使用async关键字,我遇到了一个语法错误:

/workspace/functions/lib/index.js:13
Step #5: app.get('XXXXXXXXX', async (req, resp) => {
Step #5: ^
Step #5: 
Step #5: SyntaxError: Unexpected token (
Step #5: at createScript (vm.js:56:10)
Step #5: at Object.runInThisContext (vm.js:97:10)
Step #5: at Module._compile (module.js:549:28)
Step #5: at Object.Module._extensions..js (module.js:586:10)
Step #5: at Module.load (module.js:494:32)
Step #5: at tryModuleLoad (module.js:453:12)
Step #5: at Function.Module._load (module.js:445:3)
Step #5: at Module.require (module.js:504:17)
Step #5: at require (internal/module.js:20:19)
Step #5: at /usr/local/lib/node_modules/firebase-tools/lib/triggerParser.js:21:11
指示节点引擎不是异步/等待感知的,即不是节点8。引擎在package.json中设置,并在我的本地环境中工作

"engines": {
    "node": "8"
  }
部署使用firebase容器,如中所述:

CloudBuild是否可以部署到不支持Node8的firebase函数的其他/内部端点,从而以静默方式降级

还是我还错过了什么

我试图通过将.tsconfig改为target es2015而不是es2017来证明这一理论,并从package.json中删除了引擎部分。结果是将函数部署到Node8函数

Step #5: deploying functions
Step #5: functions: ensuring necessary APIs are enabled...
Step #5: functions: all necessary APIs are enabled
Step #5: functions: preparing functions directory for uploading...
Step #5: functions: packaged functions (91.42 KB) for uploading
Step #5: functions: functions folder uploaded successfully
Step #5: functions: updating Node.js 8 function XXXXXX(us-central1)...
Step #5: functions[XXXXXXX(us-central1)]: Successful update operation.
Step #5:
Step #5: Deploy complete!

我认为这是因为node 8函数已经存在,所以它只是一个更新而不是创建,但可能表示代码解析器基于node6,并且在通过cloudbuild部署时忽略引擎设置?

Firebase工具将解析代码,查找函数触发器名称,这似乎就是它出错的地方

我猜您的自定义容器
gcr.io/[PROJECT\u NAME]/firebase
运行的节点版本与ES2017/ES8
async/await
关键字不兼容

您需要确保您的容器至少运行节点v7.6.0


希望这能有所帮助。

太棒了,谢谢@Robula。CloudBuild文档显示了使用node:borbon作为firebase的容器,但这是node 6。我换成了碳,它开始工作了。
Step #5: deploying functions
Step #5: functions: ensuring necessary APIs are enabled...
Step #5: functions: all necessary APIs are enabled
Step #5: functions: preparing functions directory for uploading...
Step #5: functions: packaged functions (91.42 KB) for uploading
Step #5: functions: functions folder uploaded successfully
Step #5: functions: updating Node.js 8 function XXXXXX(us-central1)...
Step #5: functions[XXXXXXX(us-central1)]: Successful update operation.
Step #5:
Step #5: Deploy complete!