René's URL Explorer Experiment


Title: Package map entry whose url resolves to a directory-form URL never matches its files · Issue #66043 · nodejs/node · GitHub

Open Graph Title: Package map entry whose url resolves to a directory-form URL never matches its files · Issue #66043 · nodejs/node

X Title: Package map entry whose url resolves to a directory-form URL never matches its files · Issue #66043 · nodejs/node

Description: Version v26.8.1 Platform Windows 11 x64 (the mechanism is platform independent; see analysis) Subsystem module, package maps What steps will reproduce the bug? A package entry whose url resolves to a directory-form URL (one ending in /) ...

Open Graph Description: Version v26.8.1 Platform Windows 11 x64 (the mechanism is platform independent; see analysis) Subsystem module, package maps What steps will reproduce the bug? A package entry whose url resolves to...

X Description: Version v26.8.1 Platform Windows 11 x64 (the mechanism is platform independent; see analysis) Subsystem module, package maps What steps will reproduce the bug? A package entry whose url resolves to...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Package map entry whose url resolves to a directory-form URL never matches its files","articleBody":"### Version\n\nv26.8.1\n\n### Platform\n\nWindows 11 x64 (the mechanism is platform independent; see analysis)\n\n### Subsystem\n\nmodule, package maps\n\n### What steps will reproduce the bug?\n\nA package entry whose `url` resolves to a *directory-form* URL (one ending in `/`) never matches any file inside it. The natural relative spellings for \"the directory above the map file\" — `\"..\"`, `\"../\"`, `\".\"`, `\"./\"` — all produce such a URL.\n\n```\nproject/\n  package.json          {\"private\":true}\n  index.cjs             console.log(require(\"dep\"));\n  node_modules/\n    .package-map.json\n    dep/package.json    {\"name\":\"dep\",\"main\":\"index.cjs\"}\n    dep/index.cjs       module.exports=\"ok\";\n```\n\n`node_modules/.package-map.json`:\n\n```json\n{\n  \"packages\": {\n    \"root\": { \"url\": \"..\", \"dependencies\": { \"dep\": \"dep\" } },\n    \"dep\": { \"url\": \"./dep\", \"dependencies\": {} }\n  }\n}\n```\n\n```console\n$ node --experimental-package-map=node_modules/.package-map.json index.cjs\n```\n\n### How often does it reproduce? Is there a required condition?\n\nAlways. The condition is that the entry's `url` resolves to a URL ending in `/`.\n\nResults for the same map with only the root `url` changed:\n\n| root `url` | result |\n| --- | --- |\n| `\"..\"` | `ERR_PACKAGE_MAP_EXTERNAL_FILE` |\n| `\"../\"` | `ERR_PACKAGE_MAP_EXTERNAL_FILE` |\n| `\".\"` | `ERR_PACKAGE_MAP_EXTERNAL_FILE` |\n| `\"./\"` | `ERR_PACKAGE_MAP_EXTERNAL_FILE` |\n| absolute `file:` URL without a trailing slash | `ok` |\n\n### What is the expected behavior? Why is that the expected behavior?\n\n`require(\"dep\")` from `index.cjs` should print `ok`. The documentation says `url` is \"An absolute or relative URL ... parsed using the WHATWG `URL` API, using the configuration file URL as base\", and puts no restriction on directory-form URLs. `\".\"` and `\"..\"` are ordinary relative URLs that denote directories, which is what a package entry points at.\n\n### What do you see instead?\n\n```\nError [ERR_PACKAGE_MAP_EXTERNAL_FILE]: Cannot resolve \"dep\" from \".../nodemap/index.cjs\": file is not within any package defined in .../nodemap/node_modules/.package-map.json\n    at PackageMap.resolve (node:internal/modules/package_map:179:13)\n    at packageMapResolve (node:internal/modules/package_map:305:14)\n    at tryPackageMapResolveCJS (node:internal/modules/cjs/loader:697:18)\n  code: 'ERR_PACKAGE_MAP_EXTERNAL_FILE'\n```\n\n### Additional information\n\nCause, in `lib/internal/modules/package_map.js` (v26.8.1):\n\n* `#parse` stores the package path unnormalized: `absolutePath = fileURLToPath(packageURL)` followed by `this.#pathToKey.set(absolutePath, key)`. For a directory-form URL this keeps the trailing separator, for example `/home/u/proj/`.\n* `#getKeyForPath` does `filePath = pathResolve(filePath)` and then walks up with `dirname`, comparing by exact string. `pathResolve` and `dirname` never yield a trailing separator except at a filesystem root, so the stored key is unreachable and `resolve()` throws `ERR_PACKAGE_MAP_EXTERNAL_FILE`.\n\nThe same reasoning applies on POSIX: `fileURLToPath` keeps the trailing `/`, and `path.posix.dirname(\"/home/u/proj/index.cjs\")` is `/home/u/proj`.\n\nSuggested fix: normalize when storing, that is `absolutePath = pathResolve(fileURLToPath(packageURL))` in `#parse`, so stored paths, duplicate detection and lookup all use the same spelling. Normalizing only in `#getKeyForPath` would leave the stored identity inconsistent.\n\nTest coverage: the fixtures in `test/fixtures/package-map/` use only `\"./name\"` style URLs, so no test exercises a directory-form URL. A regression test could add an entry with `url: \"..\"` and require a dependency from a file in that directory.\n\nThis is not the same as #65501 / #65502, which concern subpaths escaping the target package directory.\n\nFound via pnpm, which writes `\"url\": \"..\"` for the workspace root importer in `node_modules/.package-map.json`, so no file at a project root can resolve a bare specifier.\n","author":{"url":"https://github.com/christopher-buss","@type":"Person","name":"christopher-buss"},"datePublished":"2026-09-15T23:50:34Z","url":"https://github.com/nodejs/node/issues/66043"}

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:3210176a-eb34-8031-8743-a1be9d567d6e
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9D2A:2973C7:7A6D6E:9EC873:6AED32E9
html-safe-nonceffbe11f4e63e4fe43cff5016233d2ff650a4e8e5f85ad579b34d475570074239
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RDJBOjI5NzNDNzo3QTZENkU6OUVDODczOjZBRUQzMkU5IiwidmlzaXRvcl9pZCI6IjU1OTM3MzYxMTIxMzI0MDM5NDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmaccbf2d2a6fc13d1c5d247d40dd233e691d669c8a7ef6ad3a8b72830f5439d17ed
hovercard-subject-tagissue:5468554136
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/66043/issue_layout
twitter:imagehttps://opengraph.githubassets.com/c3d5310c5e6e14cc0212895d526b54aa64ff13bf20d31bee4df5080b9e27d4b6/nodejs/node/issues/66043
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/c3d5310c5e6e14cc0212895d526b54aa64ff13bf20d31bee4df5080b9e27d4b6/nodejs/node/issues/66043
og:image:altVersion v26.8.1 Platform Windows 11 x64 (the mechanism is platform independent; see analysis) Subsystem module, package maps What steps will reproduce the bug? A package entry whose url resolves to...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamechristopher-buss
hostnamegithub.com
expected-hostnamegithub.com
Nonee51d0b7b5ab34b1688c05b54c3ed17b8658b2fa9bca973a9c740683ccb12cf4a
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
release59ebb7b901cc154ecc179a44f266fcf69f343b30
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/nodejs/node/issues/66043#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F66043
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%2F66043
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/66043
Reloadhttps://github.com/nodejs/node/issues/66043
Reloadhttps://github.com/nodejs/node/issues/66043
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/66043
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/66043
#66054https://github.com/nodejs/node/pull/66054
Package map entry whose url resolves to a directory-form URL never matches its fileshttps://github.com/nodejs/node/issues/66043#top
#66054https://github.com/nodejs/node/pull/66054
https://github.com/christopher-buss
christopher-busshttps://github.com/christopher-buss
on Sep 15, 2026https://github.com/nodejs/node/issues/66043#issue-5468554136
#65501https://github.com/nodejs/node/issues/65501
#65502https://github.com/nodejs/node/pull/65502
nodejs-github-bothttps://github.com/nodejs-github-bot
completedhttps://github.com/nodejs/node/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#66054https://github.com/nodejs/node/pull/66054
on Sep 25, 2026https://github.com/nodejs/node/issues/66043#event-31839891374
nodejs-github-bothttps://github.com/nodejs-github-bot
on Sep 25, 2026https://github.com/nodejs/node/issues/66043#event-31839891379
module: normalize package map pathshttps://github.com/nodejs/node/commit/0551dee5f99eab5e09c8bbf9bf4d288b1195f538
0551deehttps://github.com/nodejs/node/commit/0551dee5f99eab5e09c8bbf9bf4d288b1195f538
aduh95https://github.com/aduh95
on Sep 27, 2026https://github.com/nodejs/node/issues/66043#event-31936994456
module: normalize package map pathshttps://github.com/nodejs/node/commit/b161cfd3b591bb70e79e43c44a9a8ef6cc0b629d
b161cfdhttps://github.com/nodejs/node/commit/b161cfd3b591bb70e79e43c44a9a8ef6cc0b629d
HoonDongKanghttps://github.com/HoonDongKang
on Sep 28, 2026https://github.com/nodejs/node/issues/66043#event-31971101924
module: normalize package map pathshttps://github.com/HoonDongKang/node/commit/4b90ed1e42a4cb85b3753aa811dacbf399b6784d
4b90ed1https://github.com/HoonDongKang/node/commit/4b90ed1e42a4cb85b3753aa811dacbf399b6784d
aduh95https://github.com/aduh95
on Sep 28, 2026https://github.com/nodejs/node/issues/66043#event-32031884936
module: normalize package map pathshttps://github.com/nodejs/node/commit/9baea3350911254f9d06ac8d6149ae06a4e95af7
9baea33https://github.com/nodejs/node/commit/9baea3350911254f9d06ac8d6149ae06a4e95af7
aduh95https://github.com/aduh95
on Oct 23, 2026https://github.com/nodejs/node/issues/66043#event-34094370933
module: normalize package map pathshttps://github.com/nodejs/node/commit/0514b1dc08a50fe5d853adca5cc2f42c23423a9f
0514b1dhttps://github.com/nodejs/node/commit/0514b1dc08a50fe5d853adca5cc2f42c23423a9f
module: normalize package map pathshttps://github.com/nodejs/node/commit/5458d21144c0c2f87700c69af5844df1244e02ce
5458d21https://github.com/nodejs/node/commit/5458d21144c0c2f87700c69af5844df1244e02ce
Sign up for freehttps://github.com/signup?return_to=https://github.com/nodejs/node/issues/66043
Sign in to commenthttps://github.com/login?return_to=https://github.com/nodejs/node/issues/66043
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.