在NodeJS上添加异步功能时出现错误
我正在尝试在async
上添加node.js v6.11
方法,但我却出现Unexpected identifier
错误。
let fs = require('fs');
let Config = require('../somefolders/config.js');
module.exports = class SomeClassName {
constructor(id = null) {
}
//Some other methods
static async test1234(param) {
}
//Some other Static methods
}
这是我们得到的错误:
Error
回答如下:屏幕快照中的错误告诉我们您正在使用不支持async
/ await
的旧版Node.js。 Node.js已经有async
/ await
多年了,但是如果我回到v7,我可以在您的屏幕截图中准确复制错误。
如果您更新到最新版本的Node.js(甚至是最新版本的代码,那代码就很好了。