Skip to content

Should npm init emit type=module? #7594

@bcherny

Description

@bcherny

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next steps

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions