gpt4 book ai didi

javascript - "SyntaxError: Unexpected token *"在 firebase 函数中使用 got(npm) 时

转载 作者:行者123 更新时间:2023-12-01 15:53:56 25 4
gpt4 key购买 nike

我正在使用 “得到” 用于 api 请求。

在本地运行 firebase 功能时效果很好。
但是,当我尝试部署时,我得到了 “SyntaxError: Unexpected token *” .

!  functions[app(us-central1)]: Deployment error.
Function failed on loading user code. Error message: Code in file index.js can't be loaded.
Is there a syntax error in your code?
Detailed stack trace: /srv/node_modules/got/dist/source/create.js:101
got.paginate = async function* (url, options) {
^

SyntaxError: Unexpected token *
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:617:28)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/srv/node_modules/got/dist/source/index.js:7:18)

据我所知,生成器函数在 node.js(版本 8)中可用。
我不知道原因。

谢谢你。

最佳答案

已解决。我自己回答。

“async function *”在 node.js 版本 10 及更高版本中可用。

我本地的 node.js 版本是 12,firebase 的 node.js 版本是 8(10 是 beta)。将 firebase 版本更改为 10 后,我就可以部署了。

但是,我放弃了在版本 10 中使用“got”并决定使用“node-fetch”。 node-fetch 适用于版本 8。

关于javascript - "SyntaxError: Unexpected token *"在 firebase 函数中使用 got(npm) 时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60646437/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com