pnpm self-update only replaces the pnpm binary — it does not update
other files in the @pnpm/exe package (setup.js, pn, pnpx, pnx all
remain from the v10 bootstrap). So @pnpm/exe/pn may not exist at all.
Instead of relying on @pnpm/exe/pn, create the aliases directly:
- pn → symlink to the pnpm binary
- pnpx/pnx → shell scripts that exec "pnpm dlx"
Also remove the setup.js call after self-update since it's no longer
needed and would run the v10 version which doesn't know about pn.
npm creates bin shims in .bin/ that point to an isolated copy in
.bin/.tools/. After self-update, setup.js fixes the main copy in
node_modules/@pnpm/exe/ but the .tools copy retains stale placeholder
files. Always replace the bin links so they point directly to the
fixed files instead of npm's broken .tools shims.
- Extract ensureAliasLinks to its own module for testability
- On Windows, create .cmd and .ps1 shims instead of symlinks
- On Unix, create symlinks (as before)
- Skip alias creation when targets don't exist (pnpm v10)
- Add vitest and 8 tests covering unix/windows/skip/no-overwrite