SyntaxError: missing ) after argument list, When using async

六月ゝ 毕业季﹏ 提交于 2019-11-30 04:56:33

Your version of NodeJS (6.11 LTS) is too old and does not support the async/await features. The syntax error is a result of the Javascript interpreter not recognizing the async token and getting confused about arguments.

Upgrade to NodeJS 7.6 or later. https://www.infoq.com/news/2017/02/node-76-async-await

In prior versions, the only way to perform asynchronous behaviour is to use promises.

If you don't want to/can't update your node version, try using babel presets. I had the same error using ES6 with jest (node v6.9.1).

Just add these two modules to your dependencies

npm install --save babel-preset-es2015 babel-preset-stage-0

And add a file .babelrc to your root dir with the following code:

{ "presets": ["es2015", "stage-0"] }

And if you are not using it already, install babel-cli and run your application with babel-node command

sudo npm install -g babel-cli

babel-node app.js
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!