无法将云功能升级到节点10

时间:2020-08-29 06:26:05

标签: firebase google-cloud-functions

尝试从节点8升级到节点10(instructions are simple),但是在尝试运行时仍然出错。 “ SyntaxError:意外的令牌'导出'”

我正在使用最新的工具(Firebase工具:8.9.2)和。我没有跑短毛绒。

有什么想法吗?

//relevant files in package.json:
{
  "engines": {
    "node": "10"
  },
  "dependencies": {
    "firebase-admin": "^8.10.0",
    "firebase-functions": "^3.11.0",
  },
}

代码比较

//previous code in node 8, does not error
exports.A = functions.pubsub
  .schedule("0 22 * * *")
  .onRun(() => bigQueryDump());
//code in node 10, throws error
export const A = functions.pubsub
  .schedule("0 22 * * *")
  .onRun(() => bigQueryDump());

1 个答案:

答案 0 :(得分:0)

您已将代码从exports.A = ...更改为export const A

the medium post you sharedofficial documentation中都提到需要进行此更改。

此外,该错误表明它不了解export

将其更改回exports.A应该可以解决该问题。

您可以看到examples in the docs仍然是节点10的格式。