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

Confusing error message when using import inside CJS file #56518

Open
nicolo-ribaudo opened this issue Jan 8, 2025 · 0 comments
Open

Confusing error message when using import inside CJS file #56518

nicolo-ribaudo opened this issue Jan 8, 2025 · 0 comments
Labels
esm Issues and PRs related to the ECMAScript Modules implementation.

Comments

@nicolo-ribaudo
Copy link
Contributor

Version

23.6.0

Platform

n/a

Subsystem

esm

What steps will reproduce the bug?

  • Create a file.cjs file containing import "path";
  • Run node file.cjs

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

/

What is the expected behavior? Why is that the expected behavior?

It should tell me that to use import inside file I need to use .mjs and not .cjs

What do you see instead?

Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.

It also offers the solution of setting "type": "module" in the package.json, but that is wrong since my file is .cjs.

Additional information

No response

@marco-ippolito marco-ippolito added the esm Issues and PRs related to the ECMAScript Modules implementation. label Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
esm Issues and PRs related to the ECMAScript Modules implementation.
Projects
None yet
Development

No branches or pull requests

2 participants