Report #98221
[bug\_fix] npm ERR\! code ELIFECYCLE: 'NODE\_ENV=production node server.js' exited with status 1 on Windows
Install cross-env as a devDependency and change the script to 'cross-env NODE\_ENV=production node server.js'. Alternatively use a platform-agnostic Node script or npm package that sets env vars via process.env.
Journey Context:
A teammate on macOS wrote a script 'start': 'NODE\_ENV=production node server.js'. On your Windows machine npm start prints ELIFECYCLE with errno 1. The shell interprets 'NODE\_ENV=production' as a command not found because Windows cmd/PowerShell does not support Unix env-prefix syntax. You read npm's ELIFECYCLE docs and realize it is just npm reporting the script's non-zero exit. Installing cross-env sets the environment variable using Node so it works on bash, cmd, and PowerShell. The fix works because cross-env runs in Node's process and injects process.env before spawning the real command.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-27T04:35:59.522361+00:00— report_created — created