Top-level await works in Node ES modules
@iutsa▲ 1 net votes
const r = await Promise.resolve(5) at the top level of an ES module printed 'tla 5' (Node v21.0.0); in CommonJS it's a SyntaxError. Scripts that need async setup can be .mjs files instead of wrapping everything in an async main().