Title: "Cannot find module" when main file not `index.js` with experimental-specifier-resolution=node · Issue #32103 · nodejs/node · GitHub
Open Graph Title: "Cannot find module" when main file not `index.js` with experimental-specifier-resolution=node · Issue #32103 · nodejs/node
X Title: "Cannot find module" when main file not `index.js` with experimental-specifier-resolution=node · Issue #32103 · nodejs/node
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...
Open Graph 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 sh...
X 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 sh...
Opengraph URL: https://github.com/nodejs/node/issues/32103
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"\"Cannot find module\" when main file not `index.js` with experimental-specifier-resolution=node","articleBody":"* **Version**: 13.9.0\r\n* **Platform**: Linux\r\n\r\n### What steps will reproduce the bug?\r\n\r\n1. Clone https://github.com/dandv/node-cant-find-module-with-main-not-index.js\r\n2. `npm start`\r\n\r\n### What is the expected behavior?\r\n\r\nThe script should display `Success!`, and does do so if `mypackage/Lib.js` is renamed to `mypackage/index.js`.\r\n\r\n### What do you see instead?\r\n\r\n```\r\ninternal/modules/esm/resolve.js:61\r\n let url = moduleWrapResolve(specifier, parentURL);\r\n ^\r\n\r\nError: 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\r\n at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:61:13)\r\n at Loader.resolve (internal/modules/esm/loader.js:85:40)\r\n at Loader.getModuleJob (internal/modules/esm/loader.js:191:28)\r\n at ModuleWrap.\u003canonymous\u003e (internal/modules/esm/module_job.js:42:40)\r\n at link (internal/modules/esm/module_job.js:41:36) {\r\n code: 'ERR_MODULE_NOT_FOUND'\r\n}\r\n```\r\n\r\n### Additional information\r\n\r\nI'm trying to run node with `-experimental-specifier-resolution=node` because [TypeScript can't output .mjs files](https://github.com/microsoft/TypeScript/issues/18442) 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`.","author":{"url":"https://github.com/dandv","@type":"Person","name":"dandv"},"datePublished":"2020-03-05T10:24:48.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":15},"url":"https://github.com/32103/node/issues/32103"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:78680e87-217c-eb48-9869-c233042dedb7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D94A:9FE98:2AA875A:3AEE866:6A4F0EFF |
| html-safe-nonce | 1a9c5044731cf0a5ab2c3a6faf395b23282040f4f8adcea28e3fb8a20e8e9d2c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOTRBOjlGRTk4OjJBQTg3NUE6M0FFRTg2Njo2QTRGMEVGRiIsInZpc2l0b3JfaWQiOiIxMTMzNzAzODQ3MDIzMTUyODk1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | a91b59598bf6882ed36a1c54c126393a33fcc831ba3afb1202b843867cb76900 |
| hovercard-subject-tag | issue:576146335 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/32103/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cd7cb58198d50d4726179ebfd62e28e96ae52c005794d02e0678727e86ed7da7/nodejs/node/issues/32103 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cd7cb58198d50d4726179ebfd62e28e96ae52c005794d02e0678727e86ed7da7/nodejs/node/issues/32103 |
| og:image:alt | 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 sh... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dandv |
| hostname | github.com |
| expected-hostname | github.com |
| None | b92d11c0aa4a77d54ef4af1078b6a15fb5a70a215b30c4ecf28889d5a8e656d9 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2b8f23afb982271f1b22258a94aede67a6b77760 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width