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

Should npm init emit type=module? #7594

Closed
2 tasks done
bcherny opened this issue Jun 14, 2024 · 4 comments
Closed
2 tasks done

Should npm init emit type=module? #7594

bcherny opened this issue Jun 14, 2024 · 4 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps

Comments

@bcherny
Copy link

bcherny commented Jun 14, 2024

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

When I run npm init, the generated package.json does not include a type field.

Expected Behavior

NodeJS has supported ES Modules since version ~12 (link). If using ES Modules is the recommended approach for JS packages targeting Node/browsers, then it may make sense to update npm init to enable ES Modules by default.

Adoption of type=module is around 10% today. By making type=module the default, I expect many more projects to use ES Modules going forward.

Steps To Reproduce

No response

Environment

No response

@bcherny bcherny added Bug thing that needs fixing Needs Triage needs review for next steps labels Jun 14, 2024
@ljharb
Copy link
Contributor

ljharb commented Jun 14, 2024

This has been discussed many times, and would be a bad default, and is not required for usage of ESM. The best way to use ESM is .mjs files.

@bcherny
Copy link
Author

bcherny commented Jun 14, 2024

@ljharb my search skills must be failing me. I'd be curious to see some of those previous discussions.

@ljharb
Copy link
Contributor

ljharb commented Jun 14, 2024

@wraithgar
Copy link
Member

This is a pretty significant feature request and the discussions are happening in the other issues listed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps
Projects
None yet
Development

No branches or pull requests

3 participants