-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Description
Is there an existing issue for this?
- I have searched the existing issues
This issue exists in the latest npm version
- I am using the latest npm
Current Behavior
In linked mode, workspaces not explicitly declared as root dependencies are intentionally not hoisted to root node_modules/. However, npm ls reports them as UNMET DEPENDENCY and exits with error code 1.
This happens because the lockfile always records auto-created edges from root to all workspaces regardless of install strategy.
Expected Behavior
npm ls should understand that undeclared workspaces are intentionally not hoisted in linked mode and should not report them as missing. The command should exit with code 0.
Steps To Reproduce
- Create a workspace project where only some workspaces are declared as root dependencies:
mkdir -p test-ls/packages/{workspace-a,workspace-b}
cat > test-ls/package.json << 'EOF'
{
"name": "test-ls",
"version": "1.0.0",
"workspaces": ["packages/*"],
"dependencies": { "workspace-a": "*" }
}
EOF
cat > test-ls/packages/workspace-a/package.json << 'EOF'
{ "name": "workspace-a", "version": "1.0.0" }
EOF
cat > test-ls/packages/workspace-b/package.json << 'EOF'
{ "name": "workspace-b", "version": "1.0.0" }
EOF- Install and run ls:
cd test-ls
npm install --install-strategy=linked
npm ls --install-strategy=linked- Output:
test-ls@1.0.0
├── workspace-a@1.0.0 -> ./packages/workspace-a
└── UNMET DEPENDENCY workspace-b@file:.../packages/workspace-b
npm error missing: workspace-b@file:.../packages/workspace-b, required by test-ls@1.0.0
Environment
- npm: 11.11.0
- Node.js: v22.20.0
- OS Name: macOS (Darwin 25.3.0)
- System Model Name: Mac
- npm config:
install-strategy=linkedReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels