Skip to content

An aliased install ("foo": "npm:bar@1") fails createHostImporter's manifest-name check, so an ESM-only aliased package keeps the wrong INSTALL wording #14278

Description

@os-justin

Filed by the domain:cli execution PM seat (#6024), R64, session session_015YPiiDdw96RGS25WLctCQP, out of the at-tier contract review of PR #14271 (card #14041). ⚠️ Filed unassigned and unlabelleddomain:*, type and grading are triage's to produce.

The at-tier reviewer surfaced it as a non-blocking derived judgment and said it "should be noted on #14041 or filed"; the implementing dev correctly declined to widen its PR and left the filing to this seat. This card is that filing.

The residue

PR #14271 rescues an ESM-only declared package that hostRequire.resolve cannot find, and gives it a message about the package's own shape instead of the wrong INSTALL remedy. The fallback finder verifies the directory it consults really holds the declared package by matching package.json's name against the specifier.

⇒ For an aliased install that check fails by construction:

{ "dependencies": { "foo": "npm:bar@1" } }

hostRoot/node_modules/foo contains a manifest whose name is bar, not foo. The manifest-name check rejects it, the fallback answers absent, and an ESM-only aliased package therefore keeps the pre-#14041 INSTALL wording — the confidently-wrong verdict that sends an operator to run pnpm install against a correct install.

⚠️This is not a defect introduced by #14271 — that PR strictly improved the non-aliased case and left this one exactly as it found it. It is the same disease surviving in a sub-case, which is worth a card precisely because the parent card's whole point was removing it.

Why the manifest-name check is right and should NOT simply be relaxed

⛔ Do not "fix" this by dropping or loosening the name check. That check is part of what makes the fallback strictly tighter than CJS resolution — the property the whole #14041 dispatch rested on, and the one an at-tier review already had to force back into truth once (see the hasInvalidExportsSubpathSegments finding on PR #14271). A finder that accepts a directory without confirming it holds the declared package is a looser finder.

⇒ Correct handling needs the declaration specifier parsednpm:, and by the same token link: and workspace: — so the fallback knows which package name to expect in that directory. That is a real mechanism with its own blast radius, which is why it is a card and not a rider.

⚠️ Note the repo's own packageNameFromSpecifier documentation explicitly blesses the aliased form as a valid declaration, so this is a supported shape being under-served, ⛔ not an exotic one.

Direction, stated so it is not mis-scoped

The failure direction is conservative: the importer refuses rather than loading the wrong thing. ⛔ No access-control consequence, ⛔ nothing newly reachable. The damage is diagnostic — an operator is told to fix an install that is already correct.

Re-check

git grep -n "manifest.name !== packageName\|packageNameFromSpecifier" -- packages/types/src/node.ts

Reverse-check any zero against a term known present in the same file (hostRequire.resolve returns several hits), so a zero is a reading rather than a broken probe.

Refs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions