You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 2, 2023. It is now read-only.
$ node index.js
internal/modules/cjs/loader.js:1047
throw new ERR_REQUIRE_ESM(filename);
^
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /tmp/foo.mjs
at Module.load (internal/modules/cjs/loader.js:1047:11)
at Function.Module._load (internal/modules/cjs/loader.js:937:14)
at Module.require (internal/modules/cjs/loader.js:1089:19)
at require (internal/modules/cjs/helpers.js:73:18)
at Object.<anonymous> (/tmp/1/index.js:1:1)
at Module._compile (internal/modules/cjs/loader.js:1200:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
at Module.load (internal/modules/cjs/loader.js:1049:32)
at Function.Module._load (internal/modules/cjs/loader.js:937:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
code: 'ERR_REQUIRE_ESM'
}
The message "Must use import to load ES Module" won't mean anything to users who don't understand the difference between CJS and ESM. If anything, I think it would encourage them to try import './foo.mjs' which is not going to work in a CJS script.
I suggest something like:
Error [ERR_REQUIRE_ESM]: This is an ES Module; it can't be loaded with require: /tmp/foo.mjs
You can import it asynchronously with import(), or you can import it from an ES Module. See [link]
The top part of this stack points to internal/modules/cjs/loader.js; it should point to index.js
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The message "Must use import to load ES Module" won't mean anything to users who don't understand the difference between CJS and ESM. If anything, I think it would encourage them to try
import './foo.mjs'
which is not going to work in a CJS script.I suggest something like:
The top part of this stack points to
internal/modules/cjs/loader.js
; it should point toindex.js
The text was updated successfully, but these errors were encountered: