René's URL Explorer Experiment


Title: `require('#x')` subpath imports fail with MODULE_NOT_FOUND under `--experimental-package-map` · Issue #66562 · nodejs/node · GitHub

Open Graph Title: `require('#x')` subpath imports fail with MODULE_NOT_FOUND under `--experimental-package-map` · Issue #66562 · nodejs/node

X Title: `require('#x')` subpath imports fail with MODULE_NOT_FOUND under `--experimental-package-map` · Issue #66562 · nodejs/node

Description: Version v26.10.0 (also v26.8.1) Platform Microsoft Windows NT 10.0.26100.0 x64 , package maps Subsystem module, package maps What steps will reproduce the bug? A CommonJS module cannot require() one of its own package's "imports" entries...

Open Graph Description: Version v26.10.0 (also v26.8.1) Platform Microsoft Windows NT 10.0.26100.0 x64 , package maps Subsystem module, package maps What steps will reproduce the bug? A CommonJS module cannot require() on...

X Description: Version v26.10.0 (also v26.8.1) Platform Microsoft Windows NT 10.0.26100.0 x64 , package maps Subsystem module, package maps What steps will reproduce the bug? A CommonJS module cannot require() on...

Opengraph URL: https://github.com/nodejs/node/issues/66562

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`require('#x')` subpath imports fail with MODULE_NOT_FOUND under `--experimental-package-map`","articleBody":"### Version\n\nv26.10.0 (also v26.8.1)\n\n### Platform\n\n```text\nMicrosoft Windows NT 10.0.26100.0 x64\n, package maps\n```\n\n### Subsystem\n\nmodule, package maps\n\n### What steps will reproduce the bug?\n\nA CommonJS module cannot `require()` one of its own package's `\"imports\"` entries when a package map is active. ESM `import` of the same specifier works.\n\n```text\npkg/package.json   {\"name\":\"pkg\",\"version\":\"1.0.0\",\"imports\":{\"#*\":\"./src/*\"},\"main\":\"./index.cjs\"}\npkg/index.cjs      module.exports = require('#util.cjs');\npkg/src/util.cjs   module.exports = 'ok';\napp/package.json   {\"type\":\"module\"}\napp/a.cjs          console.log(require('pkg'));\nmap.json           {\"packages\":{\"app\":{\"url\":\"./app\",\"dependencies\":{\"pkg\":\"pkg\"}},\"pkg\":{\"url\":\"./pkg\",\"dependencies\":{}}}}\n```\n\n```console\n$ node --experimental-package-map=map.json app/a.cjs\nError: Cannot find module '#util.cjs'\n```\n\n### How often does it reproduce? Is there a required condition?\n\nAlways, when `--experimental-package-map` is set and a CommonJS module requires a `#` specifier.\n\n### What is the expected behavior? Why is that the expected behavior?\n\n`ok` is printed, as it is without the flag.\n\nThe `require()` algorithm in [modules.md](https://github.com/nodejs/node/blob/c89ec290f0f82f544e39e6e5f2eab3b6de2c1cca/doc/api/modules.md?plain=1#L342-L358) runs `LOAD_PACKAGE_IMPORTS` (step 4) and `LOAD_PACKAGE_SELF` (step 5) before `LOAD_PACKAGE_MAP` (step 6). The ESM resolver also sends `#` specifiers to [`packageImportsResolve`](https://github.com/nodejs/node/blob/c89ec290f0f82f544e39e6e5f2eab3b6de2c1cca/lib/internal/modules/esm/resolve.js#L828-L829) and asks the map only in [`packageResolve`](https://github.com/nodejs/node/blob/c89ec290f0f82f544e39e6e5f2eab3b6de2c1cca/lib/internal/modules/esm/resolve.js#L737-L740).\n\n### What do you see instead?\n\n```console\nError: Cannot find module '#util.cjs'\n  code: 'MODULE_NOT_FOUND'\n```\n\n### Additional information\n\nCause, in `lib/internal/modules/cjs/loader.js` (main at c89ec290f0):\n\n* [`Module._resolveFilename`](https://github.com/nodejs/node/blob/c89ec290f0f82f544e39e6e5f2eab3b6de2c1cca/lib/internal/modules/cjs/loader.js#L1526-L1531) calls `tryPackageMapResolveCJS` for every request that is not relative and not absolute. `#` requests are included.\n* [`tryPackageMapResolveCJS`](https://github.com/nodejs/node/blob/c89ec290f0f82f544e39e6e5f2eab3b6de2c1cca/lib/internal/modules/cjs/loader.js#L697-L712) throws MODULE_NOT_FOUND when the map has no entry for the request.\n* The [`#` imports block](https://github.com/nodejs/node/blob/c89ec290f0f82f544e39e6e5f2eab3b6de2c1cca/lib/internal/modules/cjs/loader.js#L1567-L1573) is never reached.\n\nSuggested fix: do the map lookup after the `#` imports step (and after `trySelf`), as the documented algorithm does, or skip the lookup for requests that start with `#`.\n\nPublished packages that use `\"imports\"` from CommonJS fail to load under a package map. For example, dependency-cruiser 18.2.0 has `require(\"#utl/try-require.cjs\")` in `src/extract/transpile/vue-template-wrap.cjs`. I found it through pnpm's `nodeExperimentalPackageMap` setting.\n\nThis was triaged using Opus 5.5 but verified by me to the best of my ability and filed by myself.","author":{"url":"https://github.com/christopher-buss","@type":"Person","name":"christopher-buss"},"datePublished":"2026-10-06T18:04:47Z","url":"https://github.com/nodejs/node/issues/66562"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:547ec7ac-2250-bf69-6c56-4f9f25a56000
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idAE1A:FF56D:10650C:161EB4:6AED3581
html-safe-nonce848704394ec1198e2e1e0d2dae4d39f505304e6ba4412e0bb7c47537704ff683
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRTFBOkZGNTZEOjEwNjUwQzoxNjFFQjQ6NkFFRDM1ODEiLCJ2aXNpdG9yX2lkIjoiMTc1NDMyMjYzOTg3MDgzNDA0OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac6bebe86149a0d831205f20dea0eab623223fdf8c72ff4367e870f1b5c90a7add
hovercard-subject-tagissue:5733146723
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/66562/issue_layout
twitter:imagehttps://opengraph.githubassets.com/e30c6463f72bba45df3c69b53388d468a6f2e65c0e5dd9304013e9e89c00284f/nodejs/node/issues/66562
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/e30c6463f72bba45df3c69b53388d468a6f2e65c0e5dd9304013e9e89c00284f/nodejs/node/issues/66562
og:image:altVersion v26.10.0 (also v26.8.1) Platform Microsoft Windows NT 10.0.26100.0 x64 , package maps Subsystem module, package maps What steps will reproduce the bug? A CommonJS module cannot require() on...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamechristopher-buss
hostnamegithub.com
expected-hostnamegithub.com
None26c92a9388ddfad3fa88d132b5d5f0b4747030233dcc4e5efb05f1cbae152184
turbo-cache-controlno-preview
go-importgithub.com/nodejs/node git https://github.com/nodejs/node.git
octolytics-dimension-user_id9950313
octolytics-dimension-user_loginnodejs
octolytics-dimension-repository_id27193779
octolytics-dimension-repository_nwonodejs/node
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id27193779
octolytics-dimension-repository_network_root_nwonodejs/node
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasec629ad99c254d306375fc8354d04321c2c362236
ui-targetcanary-1
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/nodejs/node/issues/66562#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F66562
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F66562
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=nodejs%2Fnode
Reloadhttps://github.com/nodejs/node/issues/66562
Reloadhttps://github.com/nodejs/node/issues/66562
Reloadhttps://github.com/nodejs/node/issues/66562
nodejshttps://github.com/nodejs
nodehttps://github.com/nodejs/node
Codehttps://github.com/nodejs/node
Issues656 (656)https://github.com/nodejs/node/issues
Pull requests665 (665)https://github.com/nodejs/node/pulls
Actionshttps://github.com/nodejs/node/actions
Projectshttps://github.com/nodejs/node/projects
Security and qualityhttps://github.com/nodejs/node/security
Insightshttps://github.com/nodejs/node/pulse
https://github.com/nodejs/node
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/66562
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/66562
#66565https://github.com/nodejs/node/pull/66565
require('#x') subpath imports fail with MODULE_NOT_FOUND under --experimental-package-maphttps://github.com/nodejs/node/issues/66562#top
#66565https://github.com/nodejs/node/pull/66565
https://github.com/christopher-buss
christopher-busshttps://github.com/christopher-buss
on Oct 6, 2026https://github.com/nodejs/node/issues/66562#issue-5733146723
modules.mdhttps://github.com/nodejs/node/blob/c89ec290f0f82f544e39e6e5f2eab3b6de2c1cca/doc/api/modules.md?plain=1#L342-L358
packageImportsResolvehttps://github.com/nodejs/node/blob/c89ec290f0f82f544e39e6e5f2eab3b6de2c1cca/lib/internal/modules/esm/resolve.js#L828-L829
packageResolvehttps://github.com/nodejs/node/blob/c89ec290f0f82f544e39e6e5f2eab3b6de2c1cca/lib/internal/modules/esm/resolve.js#L737-L740
c89ec29https://github.com/nodejs/node/commit/c89ec290f0f82f544e39e6e5f2eab3b6de2c1cca
Module._resolveFilenamehttps://github.com/nodejs/node/blob/c89ec290f0f82f544e39e6e5f2eab3b6de2c1cca/lib/internal/modules/cjs/loader.js#L1526-L1531
tryPackageMapResolveCJShttps://github.com/nodejs/node/blob/c89ec290f0f82f544e39e6e5f2eab3b6de2c1cca/lib/internal/modules/cjs/loader.js#L697-L712
# imports blockhttps://github.com/nodejs/node/blob/c89ec290f0f82f544e39e6e5f2eab3b6de2c1cca/lib/internal/modules/cjs/loader.js#L1567-L1573
nodejs-github-bothttps://github.com/nodejs-github-bot
on Oct 11, 2026https://github.com/nodejs/node/issues/66562#event-32993004630
module: fix require of imports with package maphttps://github.com/nodejs/node/commit/6b07f2fb5d685c23f600049f5a44d0d5fd8ca657
6b07f2fhttps://github.com/nodejs/node/commit/6b07f2fb5d685c23f600049f5a44d0d5fd8ca657
nodejs-github-bothttps://github.com/nodejs-github-bot
completedhttps://github.com/nodejs/node/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#66565https://github.com/nodejs/node/pull/66565
on Oct 11, 2026https://github.com/nodejs/node/issues/66562#event-32993004691
richardlauhttps://github.com/richardlau
on Oct 12, 2026https://github.com/nodejs/node/issues/66562#event-33063975576
module: fix require of imports with package maphttps://github.com/nodejs/node/commit/d691bda2e0b4a1d7736726d73e86c7bd0cbc05da
d691bdahttps://github.com/nodejs/node/commit/d691bda2e0b4a1d7736726d73e86c7bd0cbc05da
module: fix require of imports with package maphttps://github.com/nodejs/node/commit/a075cfe9b2a89a8db150d0df17885b6f329e9f42
a075cfehttps://github.com/nodejs/node/commit/a075cfe9b2a89a8db150d0df17885b6f329e9f42
module: fix require of imports with package maphttps://github.com/nodejs/node/commit/bd567f8bd6c624326074a3a8a968d53b5c3080be
bd567f8https://github.com/nodejs/node/commit/bd567f8bd6c624326074a3a8a968d53b5c3080be
aduh95https://github.com/aduh95
on Oct 23, 2026https://github.com/nodejs/node/issues/66562#event-34094458501
module: fix require of imports with package maphttps://github.com/nodejs/node/commit/15b65239bab663f5959313b5fee54494daa666b3
15b6523https://github.com/nodejs/node/commit/15b65239bab663f5959313b5fee54494daa666b3
module: fix require of imports with package maphttps://github.com/nodejs/node/commit/f4dead1330bf3178b925b4839b758aae53043046
f4dead1https://github.com/nodejs/node/commit/f4dead1330bf3178b925b4839b758aae53043046
Sign up for freehttps://github.com/signup?return_to=https://github.com/nodejs/node/issues/66562
Sign in to commenthttps://github.com/login?return_to=https://github.com/nodejs/node/issues/66562
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.