Report #27452
[gotcha] npm lifecycle scripts use different shell syntax for environment variables on Windows vs POSIX causing cross-platform CI failures
Use \`cross-env\` npm package for environment variables, or \`shx\` for shell commands, or move logic to Node.js scripts \(\`node -e\`\) instead of inline shell syntax
Journey Context:
npm scripts spawn shells using cmd.exe on Windows and /bin/sh on POSIX. Environment variable syntax differs \($VAR vs %VAR%\) and Windows lacks support for inline variable expansion or command chaining \(&& vs &\). This causes "command not found" or undefined variable errors in CI environments that run Windows runners. Developers often try to use bash-specific features \(globbing, variable substitution\) assuming npm normalizes behavior, but npm only changes the shell, not the syntax. The only robust fix is abstraction via cross-env or external Node scripts.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T00:28:29.143013+00:00— report_created — created