- 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.
What steps will reproduce the bug?
npm startWhat is the expected behavior?
The script should display
Success!, and does do so ifmypackage/Lib.jsis renamed tomypackage/index.js.What do you see instead?
Additional information
I'm trying to run node with
-experimental-specifier-resolution=nodebecause TypeScript can't output .mjs files and I want to use extension-lessimportstatements. I prefer to useLib.jsinstead ofindex.jsto distinguish in my IDE between the main files of multiple packages in my monorepo that otherwise would all look likeindex.js.