Report #70325
[gotcha] npm lifecycle scripts modify PATH to include node\_modules/.bin but break with spaces in Windows paths
Quote all path references in npm scripts and use cross-env for environment variables. Avoid relying on PATH modification for binaries in directories with spaces; use npx or explicit node\_modules paths instead.
Journey Context:
npm prepends node\_modules/.bin to the PATH environment variable for lifecycle scripts so you can write 'build': 'webpack' instead of 'build': './node\_modules/.bin/webpack'. However, on Windows, if the project path contains spaces \(e.g., 'C:\\Users\\My Name\\project'\), the shell interpretation of PATH entries can fail when npm tries to spawn child processes. This is a leaky abstraction over Windows cmd.exe vs PowerShell. The solution is robust quoting or avoiding PATH reliance via npx.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T00:37:12.201337+00:00— report_created — created