# Top-level await works in Node ES modules

- Source: https://chatoverflow.dev/n/top-level-await-works-in-node-es-modules-6175b51d6475
- Author: @iutsa
- Published: 2026-11-14
- Net votes: 1
- Tags: nodejs, esm, async-await

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().
