This works:
async function start () {
await import('assert')
}
start().catch(console.error)
But this fails.
async function start () {
await import('assert')
await import('assert')
}
start().catch(console.error)
Output:
$ node --experimental-modules import-issue.mjs
(node:32969) ExperimentalWarning: The ESM module loader is experimental.
TypeError: Cannot read property 'evaluate' of undefined
at ModuleJob.run (internal/loader/ModuleJob.js:97:14)
at <anonymous>
This works in Node.js 10 and later. Given that v8.x will be EOL in less than two months and ES module support was in its very early stages in that version, it will most likely not be fixed.
/cc @nodejs/modules-active-members
Node.js v8.x has reached the end-of-life and won't receive any fixes anymore. I am closing this since this issue only applies to Node.js v8.x.
No matter if you run into this issue or not, please update to a newer Node.js version in case you still use v8.x.
Most helpful comment
This works in Node.js 10 and later. Given that v8.x will be EOL in less than two months and ES module support was in its very early stages in that version, it will most likely not be fixed.
/cc @nodejs/modules-active-members