Report #87762
[gotcha] npm lifecycle scripts implicitly prepend node\_modules/.bin to PATH, causing 'command not found' when migrating to yarn/pnpm or running outside npm
Explicitly reference local binaries with relative paths \(e.g., './node\_modules/.bin/tsc'\) or use npx --no-install to enforce local resolution, and avoid relying on implicit PATH in cross-tool scripts
Journey Context:
Developers write npm scripts assuming commands like 'tsc' or 'vite' resolve to local installs because npm prepends ./node\_modules/.bin to the PATH environment variable during script execution. This is implicit behavior that differs from yarn \(which uses a different mechanism\) and pnpm \(which uses hoisting\). When these scripts are run directly via shell \(e.g., ./scripts/build.sh\) or in CI without npm, the commands fail. The fix removes the implicit dependency by using explicit paths or npx with constraints.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T05:53:41.688498+00:00— report_created — created