EnderShadow8
EnderShadow8

Reputation: 1050

Top level await not working with ESM in Node.js

I'm using this benchmark however when running src/bench.js Node throws this error:

      let result = await run_bench(path, config);
                   ^^^^^

SyntaxError: Unexpected reserved word
    at Loader.moduleStrategy (internal/modules/esm/translators.js:88:18)
    at async link (internal/modules/esm/module_job.js:41:21)

Top level await is supposed to work in ESM modules, and the package.json definitely has "type": "module". I also tried using mjs but still didn't work.

This isn't my code, so I'm unsure how to even start to fix it.

I'm using Node.js v14.4.0.

Upvotes: 0

Views: 1868

Answers (1)

Quentin
Quentin

Reputation: 943996

Support for top level await (without passing a command line argument to enable it as an experimental feature) was introduced in Node.js 14.8.0.

The version of Node.js you are using is too old.

Upvotes: 3

Related Questions