fix(ls): suppress false UNMET DEPENDENCYs in linked strategy#9095
Merged
wraithgar merged 2 commits intonpm:latestfrom Mar 10, 2026
Merged
Conversation
a633541 to
dc003fb
Compare
wraithgar
reviewed
Mar 10, 2026
lib/commands/ls.js
Outdated
| // 2. Dev edges on non-root packages: store package link targets have no parent in the node tree, so they are treated as "top" nodes and their devDependencies are loaded as edges. Those devDeps are never installed. | ||
| const filterLinkedStrategyEdges = ({ node, currentDepth }) => { | ||
| const declaredDeps = currentDepth === 0 | ||
| ? new Set(Object.keys(Object.assign({}, |
Member
There was a problem hiding this comment.
I think this approach is cleaner than what we're doing with things like this.#rootDeclaredDeps in makeIdealGraph.
this.#rootDeclaredDeps = new Set([
...Object.keys(rootPkg.dependencies || {}),
...(!omit.has('dev') ? Object.keys(rootPkg.devDependencies || {}) : []),
...(!omit.has('optional') ? Object.keys(rootPkg.optionalDependencies || {}) : []),
...(!omit.has('peer') ? Object.keys(rootPkg.peerDependencies || {}) : []),
])could become
this.#rootDeclaredDeps = new Set(Object.keys(Object.assign({},
rootPkg.dependencies,
(!omit.has('dev') && rootPkg.devDependencies),
(!omit.has('optional') && rootPkg.optionalDependencies),
(!omit.has('peer') && rootPkg.peerDependencies),
)))
Contributor
Author
There was a problem hiding this comment.
Yes! That refactor in isolated-reifier.js would be a nice follow-up.
Contributor
Author
There was a problem hiding this comment.
Or should I make that change here? It doesn't seem to affect the coverage, so the changes should be minimal.
wraithgar
reviewed
Mar 10, 2026
wraithgar
approved these changes
Mar 10, 2026
Merged
manzoorwanijk
added a commit
to manzoorwanijk/npm-cli
that referenced
this pull request
Mar 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In continuation of our exploration of using
install-strategy=linkedin the Gutenberg monorepo, which powers the WordPress Block Editor.In linked install strategy,
npm lsreports two types of false UNMET DEPENDENCYs:Undeclared workspaces: The root node always creates workspace edges for all workspaces (from the
workspacesfield in package.json), but in linked mode only workspaces explicitly declared in dependencies are hoisted toroot/node_modules/. Undeclared workspaces are intentionally absent, yetnpm lsreports them as missing.devDependencies of store packages: Store package link targets (at
.store/<key>/node_modules/<name>) have no parent in the node tree, so they are treated as "top" nodes and theirdevDependenciesare loaded as edges. Those devDeps are never installed, butnpm ls --allreports them as UNMET DEPENDENCY.This PR adds a
filterLinkedStrategyEdgesfilter inls.jsthat is only active wheninstallStrategy === 'linked'. It skips workspace edges for undeclared workspaces at the root level and skips dev edges for non-root packages (store packages).References
Fixes #9090
Fixes #9092