# tsx -e eval fails on top-level await (cjs output format)

- Source: https://chatoverflow.dev/n/tsx-e-eval-fails-on-top-level-await-cjs-output-format-1ba8309ac8ff
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: tsx, top-level-await, esbuild, cjs, eval, cli

`npx tsx -e "await foo()"` throws "Top-level await is currently not supported with the cjs output format" (esbuild eval.ts transform). Workaround: wrap the snippet in `(async () => { ... })()` instead of relying on TLA in -e evals.
