Visitar URL original
`pnpm bin` in a project subdirectory prints `<cwd>/node_modules/.bin` since v12 · Issue #14622 · pnpm/pnpm · GitHub
Skip to content

pnpm bin in a project subdirectory prints <cwd>/node_modules/.bin since v12 #14622

Closed

Description

@karlhorky

Verify latest release

  • I verified that the issue exists in the latest pnpm release

pnpm version

No response

Which area(s) of pnpm are affected? (leave empty if unsure)

CLI

Link to the code that reproduces this issue or a replay of the bug

No response

Reproduction steps

$ mkdir -p /tmp/pnpm-bin-repro/sub && cd /tmp/pnpm-bin-repro

$ echo '{"name":"repro"}' > package.json

$ mkdir -p node_modules/.bin

$ cd sub

$ npx pnpm@11.25.0 bin
/private/tmp/pnpm-bin-repro/node_modules/.bin

$ npx pnpm@12.3.4 bin
/private/tmp/pnpm-bin-repro/sub/node_modules/.bin

$ ls "$(npx pnpm@12.3.4 bin 2>/dev/null)"
ls: /private/tmp/pnpm-bin-repro/sub/node_modules/.bin: No such file or directory

Every pnpm 12 release prints the cwd path:

$ for version in 10.0.0 11.0.0 11.24.0 11.25.0 12.0.0 12.1.0 12.2.0 12.3.4; do printf '%-8s ' "$version"; npx -y pnpm@$version bin 2>/dev/null; done
10.0.0   /private/tmp/pnpm-bin-repro/node_modules/.bin
11.0.0   /private/tmp/pnpm-bin-repro/node_modules/.bin
11.24.0  /private/tmp/pnpm-bin-repro/node_modules/.bin
11.25.0  /private/tmp/pnpm-bin-repro/node_modules/.bin
12.0.0   /private/tmp/pnpm-bin-repro/sub/node_modules/.bin
12.1.0   /private/tmp/pnpm-bin-repro/sub/node_modules/.bin
12.2.0   /private/tmp/pnpm-bin-repro/sub/node_modules/.bin
12.3.4   /private/tmp/pnpm-bin-repro/sub/node_modules/.bin

Describe the Bug

pnpm 12 prints <cwd>/node_modules/.bin, pnpm 10 and 11 printed the node_modules/.bin of the nearest ancestor directory containing a package.json. Run from a subdirectory, the pnpm 12 path does not exist, so tools spawning executables out of pnpm bin fail with ENOENT. Found in UpLeveled Preflight, which spawns depcheck out of it (upleveled/preflight#774).

#12703 ported the command to Rust as dir.join("node_modules").join(".bin"), describing --dir as "matching pnpm's config.dir (the cwd, not the workspace root)". pnpm 11 resolves config.dir from npm's localPrefix, which is the walk-up to the nearest package.json:

The change is not mentioned in the pnpm 12 release notes or in What's different in pnpm 12.

Expected Behavior

pnpm bin prints the node_modules/.bin of the nearest ancestor directory containing a package.json, where the project's executables are installed, as in pnpm 10 and 11.

Which Node.js version are you using?

v24.13.0

Which operating systems have you used?

  • macOS
  • Windows
  • Linux

If your OS is a Linux based, which one it is? (Include the version if relevant)

No response

Activity

  1. self-assigned this
    on Sep 7, 2026
  2. added a commit that references this issue on Sep 7, 2026
    2a47c58
  3. added 2 commits that reference this issue on Sep 15, 2026
    342ef2d
    6778157
  4. added a commit that references this issue on Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions