如何在node.js 7.6 +
中指定异步类方法以下方法正在打破:
class A{
async abc(){
//
return 'abc';
}
}
和
class A{
async function abc(){
//
return 'abc';
}
}
发生错误
async abc(ll){
^^^^
SyntaxError: Unexpected identifier
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:542:28)
启动应用。 node src / main.js
package.json和Dependencies如下。
{
"name": "abc",
"version": "0.0.1",
"description": "on",
"main": "src/mn.js",
"dependencies": {
"underscore":"*",
"moment": "2.12.0",
"moment-timezone": "0.5.3",
"url": "0.11.0",
"lodash":"4.11.1",
"request": "*",
"shelljs": "0.5.3",
"busboy": "0.2.13",
"bluebird": "3.3.1",
"q": "1.4.1",
"nodemailer": "2.2.*",
"mongojs": "2.3.0",
"mongodb": "2.1.7",
"generic-pool": "2.4.0",
"priorityqueuejs": "1.0.0",
"object-path": "0.9.2",
"merge": "1.2.0",
"amqp": "0.2.4",
"request": "2.69.0",
"kafka": "0.2.3",
"mongo-oplog":"1.0.1",
"websocket":"1.0.23",
"ws":"1.1.1",
"node-sass": "3.8.*",
"jsonwebtoken": "5.7.0",
"winston": "1.1.1",
"winston-logstash": "0.2.11",
"xlsx": "0.8.0"
},
"devDependencies": {
},
"scripts": {
}
}
注意:我也有Blueird,因为我的代码的一部分是使用bluebird,是那么好/