Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repl: -r doesn't work with ESM #42547

Closed
wmertens opened this issue Mar 31, 2022 · 1 comment
Closed

repl: -r doesn't work with ESM #42547

wmertens opened this issue Mar 31, 2022 · 1 comment

Comments

@wmertens
Copy link

Version

16.14.2

Platform

Linux wmertens-nixos 5.15.3-zen1 #1-NixOS ZEN SMP Tue Jan 1 00:00:00 UTC 1980 x86_64 GNU/Linux

Subsystem

repl

What steps will reproduce the bug?

set type: "module" in package.json, and then try to run node -r ./some-module.js. It will fail with the error

[Error [ERR_REQUIRE_ESM]: require() of ES Module .../some-module.js not supported.
Instead change the require of repl.js in null to a dynamic import() which is available in all CommonJS modules.] {
  code: 'ERR_REQUIRE_ESM'

I suppose that when using -r in an ESM repo, the repl must use await import instead of require for -r arguments?

How often does it reproduce? Is there a required condition?

every time when the project is ESM and you try to load a local file as a module

What is the expected behavior?

it works

What do you see instead?

'ERR_REQUIRE_ESM'

Additional information

No response

@wmertens
Copy link
Author

Actually, looks like this is a duplicate of #35103

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant