I am on running Node version 14.15.3
Welcome to Node.js v14.15.3.
I thought it was cool that you could use await
now in top level scripts, so I tried it. To not my surprise, it didn't work.
const myfunc = async () => {
return new Promise((res, rej) => {
setTimeout(() => {res()},1000)
})
}
await myfunc();
SyntaxError: await is only valid in async function at wrapSafe (internal/modules/cjs/loader.js:979:16) at Module._compile (internal/modules/cjs/loader.js:1027:27) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10) at Module.load (internal/modules/cjs/loader.js:928:32) at Function.Module._load (internal/modules/cjs/loader.js:769:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) at internal/main/run_main_module.js:17:47
Not sure what else to say. It just doesn't work.. Did it break? Did it ever really work?