I am porting some code I wrote in the browser, and discovered I can't seem to create asynchronous methods in NodeJS
class Test{
async hello(){
return "hello";
}
}
(async function(){
let test = new Test();
let hello = await test.hello();
console.log(hello);
})();
When I execute this, I get an error:
/home/ubuntu/workspace/test.js:2
async hello(){
^^^^^
SyntaxError: Unexpected identifier
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Timeout.Module.runMain [as _onTimeout] (module.js:604:10)
at ontimeout (timers.js:386:14)
at tryOnTimeout (timers.js:250:5)
Is this just not possible in node, or am I don't something incorrect here?
I am running Node 8.x