Skip to content

fix: skip isolated tree for workspace-filtered installs with linked strategy#9040

Open
manzoorwanijk wants to merge 2 commits intonpm:latestfrom
manzoorwanijk:fix/linked-workspace-install-crash
Open

fix: skip isolated tree for workspace-filtered installs with linked strategy#9040
manzoorwanijk wants to merge 2 commits intonpm:latestfrom
manzoorwanijk:fix/linked-workspace-install-crash

Conversation

@manzoorwanijk
Copy link
Contributor

@manzoorwanijk manzoorwanijk commented Feb 27, 2026

In continuation of our exploration of using install-strategy=linked in the Gutenberg monorepo, which powers the WordPress Block Editor, this is a follow-up of the fixes from #8996.

npm install --workspace crashes with a TypeError when install-strategy=linked is configured.

The isolated tree built by _createIsolatedTree() is structurally incompatible with workspace-filtered installs:

  1. root.children is an Array, not a Map — workspace filtering calls .get(ws) which doesn't exist on Array
  2. inventory.query() is a stub returning [] — the set root setter can't resolve Link targets during post-reify re-rooting
  3. The filterSet computed against the isolated tree becomes invalid after the tree is swapped back to the original

npm 11.x throws:

TypeError: Cannot read properties of null (reading 'package')
    at set root (lib/node.js:797:35)

npm 10.x throws:

TypeError: this.idealTree.children.get is not a function
    at Arborist.[diffTrees] (lib/arborist/reify.js:441:45)

This PR:

  1. Skips _createIsolatedTree() when --workspace is active, falling back to the normal reify path with real Node/Link instances. A subsequent full npm install restructures everything back to linked layout. The isolated tree was designed for full npm install, not filtered installs.

  2. Handles unsupported spec types in isRegistryDependency — packages with link: specs in their dependencies (e.g. link:.) cause npa to throw EUNSUPPORTEDPROTOCOL when isRegistryDependency is accessed during lockfile save. The fix catches the error and treats unsupported spec types as non-registry dependencies.

References

Fixes #9038

…trategy

The isolated tree built by _createIsolatedTree() uses plain objects with Array children and a stub inventory.query(), which are incompatible with workspace filtering in _diffTrees() and the post-reify re-rooting logic.

Skip the isolated tree swap when --workspace is specified and fall back to the normal reify path.
@manzoorwanijk manzoorwanijk requested a review from a team as a code owner February 27, 2026 17:02
Packages with link: specs in their dependencies (e.g. link:.) cause
npa to throw EUNSUPPORTEDPROTOCOL when isRegistryDependency is accessed
during lockfile save. Catch the error and treat unsupported spec types
as non-registry dependencies.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] npm install --workspace crashes with install-strategy=linked

1 participant