Report #93450
[gotcha] npm lifecycle scripts modify PATH differently on Windows vs Unix and between pre/post hooks
Use npx or fully qualified paths \(./node\_modules/.bin/cmd\) instead of relying on bare command names in nested scripts; or explicitly set PATH in cross-platform tools like cross-env.
Journey Context:
npm prepends node\_modules/.bin to PATH for lifecycle scripts, but the behavior varies: Windows uses different path separators, and pre/post scripts inherit the modified PATH differently than the main script. Additionally, yarn and pnpm handle this differently, causing "command not found" errors when migrating between package managers. The reliable fix is to avoid assuming PATH inheritance works identically across environments and instead invoke binaries explicitly or through npx, which handles the resolution correctly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T15:26:38.660967+00:00— report_created — created