-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
Closed
Labels
confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.esmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.help wantedIssues that need assistance from volunteers or PRs that need help to proceed.Issues that need assistance from volunteers or PRs that need help to proceed.
Description
- Version: 13.9.0
- Platform: Linux
What steps will reproduce the bug?
- Clone https://github.com/dandv/node-cant-find-module-with-main-not-index.js
npm start
What is the expected behavior?
The script should display Success!
, and does do so if mypackage/Lib.js
is renamed to mypackage/index.js
.
What do you see instead?
internal/modules/esm/resolve.js:61
let url = moduleWrapResolve(specifier, parentURL);
^
Error: Cannot find module /home/dandv/prg/node-cant-find-module-with-main-not-index.js/mypackage imported from /home/dandv/prg/node-cant-find-module-with-main-not-index.js/run.js
at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:61:13)
at Loader.resolve (internal/modules/esm/loader.js:85:40)
at Loader.getModuleJob (internal/modules/esm/loader.js:191:28)
at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:42:40)
at link (internal/modules/esm/module_job.js:41:36) {
code: 'ERR_MODULE_NOT_FOUND'
}
Additional information
I'm trying to run node with -experimental-specifier-resolution=node
because TypeScript can't output .mjs files and I want to use extension-less import
statements. I prefer to use Lib.js
instead of index.js
to distinguish in my IDE between the main files of multiple packages in my monorepo that otherwise would all look like index.js
.
jkrems, himself65, valoranthead, duka94, acbreton and 10 morebrainkim and valorantheadbrainkim and valorantheadbrainkim, valoranthead, AliRazaSharafat and imrim12brainkim, valoranthead and sderbush-ttbrainkim and alekseykulikovbrainkim and valoranthead
Metadata
Metadata
Assignees
Labels
confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.esmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.help wantedIssues that need assistance from volunteers or PRs that need help to proceed.Issues that need assistance from volunteers or PRs that need help to proceed.