-
Notifications
You must be signed in to change notification settings - Fork 29.3k
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
A package.json lacking a "type" field is not treated as if it contained "type": "commonjs" #30245
Labels
confirmed-bug
Issues with confirmed bugs.
esm
Issues and PRs related to the ECMAScript Modules implementation.
Comments
kimamula
changed the title
Top-level "type" field of package.json file does not default to "commonjs"
A package.json lacking a "type" field is not treated as if it contained "type": "commonjs"
Nov 4, 2019
guybedford
added a commit
to guybedford/node
that referenced
this issue
Nov 5, 2019
3 tasks
Thanks for the really clear bug report here and for testing this edge case. You are exactly right about the expectations here. I've posted a fix for this in #30256. |
guybedford
added
confirmed-bug
Issues with confirmed bugs.
esm
Issues and PRs related to the ECMAScript Modules implementation.
labels
Nov 5, 2019
MylesBorins
pushed a commit
that referenced
this issue
Nov 17, 2019
Fixes: #30245 PR-URL: #30256 Reviewed-By: Myles Borins <[email protected]> Reviewed-By: Jan Krems <[email protected]>
targos
pushed a commit
that referenced
this issue
Dec 1, 2019
Fixes: #30245 PR-URL: #30256 Reviewed-By: Myles Borins <[email protected]> Reviewed-By: Jan Krems <[email protected]>
MylesBorins
pushed a commit
that referenced
this issue
Dec 17, 2019
Fixes: #30245 PR-URL: #30256 Reviewed-By: Myles Borins <[email protected]> Reviewed-By: Jan Krems <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
confirmed-bug
Issues with confirmed bugs.
esm
Issues and PRs related to the ECMAScript Modules implementation.
ECMAScript modules Document says:
To confirm this, I have created folders and files as follows (file contents are written after colons).
When I execute
$ node --experimental-modules ./sub1/foo.js
in theroot
folder, it results in an errorError [ERR_REQUIRE_ESM]: Must use import to load ES Module
, while$ node --experimental-modules ./sub2/foo.js
does not throw any error.Therefore, the document is incorrect and it is likely non-top-level
"type"
fields inpackage.json
file affects whether the JS files are treated as ES modules or CommonJS modules.The text was updated successfully, but these errors were encountered: