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.
Uh oh!
There was an error while loading. Please reload this page.
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: