我将firebase-functions模块升级到了3.0.1。现在,当我部署Cloud Functions时,我收到警告消息:
⚠functions:将函数部署到Node6运行时,已弃用。Node 8是可用的,并且是推荐的运行时。
然后,部署失败,并显示以下内容:
Function failed on loading user code. Error message: Code in file lib/index.js can't be loaded.
Is there a syntax error in your code?
Detailed stack trace: /user_code/node_modules/firebase-functions/lib/providers/https.js:282
const func = async (req, res) => {
^
SyntaxError: Unexpected token (
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/user_code/node_modules/firebase-functions/lib/index.js:39:15)
我该如何解决这个问题呢?
发布于 2019-06-13 07:13:39
在过去,节点6是默认的目标运行时。现在,节点6已过期LTS (长期支持)。在CLI版本6.8.0中,节点6已弃用,建议您以节点8为目标进行部署。现在,从firebase-functions@3.0.0开始,节点6的支持被完全移除,您必须在package.json中显式地以节点8为目标:
{
// other configurations here…
"dependencies": {
},
// Add an “engines” child to choose a node version, here it’s node 8.
"engines": {
"node": "8"
}
}
此版本中的另一个相关更改是对firebase-admin 8.x的依赖,这也删除了对节点6的支持。
错误消息本身指示不能识别关键字async
,这是节点6不支持的。
https://stackoverflow.com/questions/56571460
复制相似问题