Skip to content

[BUG] linked strategy: npm ls reports undeclared workspaces as UNMET DEPENDENCY #9090

Description

@manzoorwanijk

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

  1. 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
  1. Install and run ls:
cd test-ls
npm install --install-strategy=linked
npm ls --install-strategy=linked
  1. Output:
[email protected]
├── [email protected] -> ./packages/workspace-a
└── UNMET DEPENDENCY workspace-b@file:.../packages/workspace-b

npm error missing: workspace-b@file:.../packages/workspace-b, required by [email protected]

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=linked

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions