Skip to content

[BUG] install-strategy=linked: npm exec -w <ws> ignores a workspace-local bin and falls back to the registry #9616

Description

@manzoorwanijk

Part of #9608.

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

This is not just a request to bump a dependency for a CVE

  • This is not solely a request to bump a dependency for a CVE

Current Behavior

A workspace depends on another workspace that provides a bin. The bin shim is correctly created in the consumer workspace's node_modules/.bin/, but npm exec -w <ws> -- <bin> under install-strategy=linked ignores it and falls through to the registry, producing npm error code E404 (exit 1). The hoisted strategy runs the local bin.

Expected Behavior

npm exec -w <ws> -- <bin> should run the workspace-local bin under the linked strategy, as it does under hoisted, without contacting the registry.

Steps To Reproduce

cd "$(mktemp -d)"
echo 'install-strategy=linked' > .npmrc
echo '{ "name": "root", "version": "1.0.0", "workspaces": ["packages/*"] }' > package.json
mkdir -p packages/a packages/tool
echo '{ "name": "a", "version": "1.0.0", "dependencies": { "tool": "*" } }' > packages/a/package.json
echo '{ "name": "tool", "version": "1.0.0", "bin": { "zz-bin": "cli.js" } }' > packages/tool/package.json
printf '#!/usr/bin/env node\nconsole.log("tool bin ok")\n' > packages/tool/cli.js
chmod +x packages/tool/cli.js
npm install >/dev/null
readlink packages/a/node_modules/.bin/zz-bin   # ../tool/cli.js  (bin from dep workspace, present)

npm exec -w a -- zz-bin
#   linked:  npm error code E404  GET https://registry.npmjs.org/zz-bin   (exit 1)
#   hoisted: prints "tool bin ok" (exit 0)

Environment

  • npm: 12.0.0-pre.1 (latest)
  • Node.js: v24.17.0
  • OS Name: macOS (Darwin 25.5.0)
  • System Model Name: MacBook (arm64)
  • npm config:
install-strategy=linked

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