docs(package-json): add documentation for type field#8793
Merged
wraithgar merged 1 commit intonpm:latestfrom Dec 3, 2025
Merged
docs(package-json): add documentation for type field#8793wraithgar merged 1 commit intonpm:latestfrom
wraithgar merged 1 commit intonpm:latestfrom
Conversation
Member
|
This likely needs a discussion. There is a similar PR on the docs themselves for the type field that has the context. The TLDR is that Node.js drives this field, npm does not parse it at all so the docs need to point to the source, and not try to recreate it in a way that needs maintenance on our end. ETA: added context to the issue too #8376 (comment) |
Contributor
Author
|
@wraithgar Thank you for the feedback! I've updated the PR to follow the same approach discussed in npm/documentation#1653 - the documentation now simply references the Node.js documentation as the source of truth, avoiding technical details that would need maintenance. Please let me know if this approach works better. |
36b90ed to
2f2e8b3
Compare
wraithgar
approved these changes
Dec 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds documentation for the
typefield in package.json, which controls whether Node.js treats .js files as ES modules or CommonJS modules.Changes
typefieldmoduleandcommonjsFixes
Closes #8376
Context
The
typefield is a crucial part of package.json for modern Node.js projects, especially with the widespread adoption of ES modules. As reported in issue #8376, this field was not documented in npm's package.json reference, which caused confusion for developers trying to understand how to configure their packages for ESM or CommonJS.This documentation clarifies:
"type": "module")"type": "commonjs")typeis omitted (CommonJS)Type of Change