node v8.16.2: importing an ESM module works the first time but not the second

Created on 13 Nov 2019  路  2Comments  路  Source: nodejs/node

  • Version: v8.16.2
  • Platform: Darwin mba4.local 19.0.0 Darwin Kernel Version 19.0.0: Thu Oct 17 16:17:15 PDT 2019; root:xnu-6153.41.3~29/RELEASE_X86_64 x86_64
  • Subsystem: ECMAScript Modules

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>
ES Modules

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

All 2 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

willnwhite picture willnwhite  路  3Comments

vsemozhetbyt picture vsemozhetbyt  路  3Comments

ksushilmaurya picture ksushilmaurya  路  3Comments

Icemic picture Icemic  路  3Comments

dfahlander picture dfahlander  路  3Comments