Report #91193
[bug\_fix] npm ERR\! code ELIFECYCLE with 'NODE\_ENV' is not recognized as an internal or external command \(Windows\) or 'set: command not found' \(Unix\)
Install \`cross-env\` \(\`npm install --save-dev cross-env\`\) and prefix the npm script command: \`"build": "cross-env NODE\_ENV=production webpack"\`. This handles cross-platform environment variable setting.
Journey Context:
Team has mixed development environment: some developers use macOS/Linux, others use Windows. The project has an npm script: \`"build": "NODE\_ENV=production webpack"\`. On macOS and Linux, the shell sets the environment variable \`NODE\_ENV\` to \`production\` and executes webpack. However, when a Windows developer runs \`npm run build\`, the command fails with "'NODE\_ENV' is not recognized as an internal or external command" because Windows \`cmd.exe\` does not support \`KEY=value\` syntax; it requires \`set KEY=value\`. If they change the script to \`"set NODE\_ENV=production && webpack"\`, it breaks on macOS with \`set: command not found\`. The team searches for a cross-platform solution and finds the \`cross-env\` npm package. They install it as a dev dependency \(\`npm i -D cross-env\`\). They update the script to \`"build": "cross-env NODE\_ENV=production webpack"\`. Now when the script runs, \`cross-env\` spawns the \`webpack\` process with \`NODE\_ENV\` correctly set in \`process.env\` using Node.js's cross-platform capabilities, regardless of the shell \(cmd, PowerShell, bash, zsh\). The build succeeds on all developer machines.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T11:39:35.650910+00:00— report_created — created