-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Closed
Labels
feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.
Description
- Version: 12.18.3
- Platform: macOS 10.15.6
- Subsystem:
What steps will reproduce the bug?
Run node
with --require
and --experimental-specifier-resolution=node
An example can be found here when running npm test
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior?
There's a way to preload a file using import
rather than require
What do you see instead?
internal/modules/cjs/loader.js:1154
throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
^
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/dlj/projects/test_import_preload/preload.js
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1154:13)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at Module._preloadModules (internal/modules/cjs/loader.js:1278:12)
at loadPreloadModules (internal/bootstrap/pre_execution.js:439:5)
at prepareMainThreadExecution (internal/bootstrap/pre_execution.js:71:3)
at internal/main/run_main_module.js:7:1 {
code: 'ERR_REQUIRE_ESM'
}
npm ERR! Test failed. See above for more details.
Additional information
It would be nice if there was a --import
or if --require
worked with import
s
Metadata
Metadata
Assignees
Labels
feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.