admin管理员组文章数量:1318564
I'm using "got" for api request.
It worked fine when running firebase functions locally. However, when I tried to deploy, I got "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._pile (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)
As far as i know, the generator function be available in node.js (version 8). I don't know the cause.
Thank you.
I'm using "got" for api request.
It worked fine when running firebase functions locally. However, when I tried to deploy, I got "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._pile (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)
As far as i know, the generator function be available in node.js (version 8). I don't know the cause.
Thank you.
Share Improve this question asked Mar 12, 2020 at 1:21 Oza OzaOza Oza 1711 silver badge8 bronze badges 2- 4 That just means the NodeJS version in the production environment is lower so it doesn't understand the generator function syntax, also I don't think Node version 8 had generator function support – Trash Can Commented Mar 12, 2020 at 1:56
- 1 @Teedeez Thanks for your ment. I looked up more about the node.js version. generator function with async was available in node.js version 10 and later. However, Version 10 for the firebase functions is a beta version, so i will consider how to deal with it. Thank you again. – Oza Oza Commented Mar 12, 2020 at 2:35
1 Answer
Reset to default 11It has been resolved. I answer myself.
"async function * " is available in node.js version 10 and later.
My local node.js version was 12, and firebase's node.js version is 8 (10 is beta). After change firebase version to 10, I was able to deploy.
But, I gave up using "got" with version 10 and decided to use "node-fetch". node-fetch works with version 8.
版权声明:本文标题:javascript - "SyntaxError: Unexpected token *" when use got(npm) in firebase functions - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742048635a2417942.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论