Report #92829
[gotcha] npm lifecycle scripts silently modify PATH with POSIX separators causing cross-platform breaks
Use cross-env package for environment variables; explicitly invoke npx instead of relying on modified PATH; restrict script syntax to POSIX sh only
Journey Context:
npm prepends node\_modules/.bin to PATH inside lifecycle scripts, but uses colon-delimited POSIX format even on Windows where the shell expects semicolons. Furthermore, npm scripts execute via sh \(Git Bash on Windows\), not cmd.exe, but environment variable syntax \($FOO vs %FOO%\) differs. This causes 'command not found' or syntax errors when scripts work locally on Windows but fail in Linux CI, or vice versa. The PATH modification is implicit and undocumented in user-facing npm docs beyond a brief mention.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T14:23:59.210280+00:00— report_created — created