Report #6169
[gotcha] npm install and npm run do not set NODE\_ENV, causing production installs to use devDependencies or dev config
Explicitly set NODE\_ENV=production in CI/CD pipelines and Dockerfiles before running npm install; do not rely on npm to infer environment from --production flag \(which only affects install behavior, not env var\).
Journey Context:
Many developers assume \`npm install --production\` sets \`NODE\_ENV=production\` for lifecycle scripts \(like postinstall\). It does not; \`--production\` only prevents devDependencies from being installed. If the shell has \`NODE\_ENV=development\` \(common in dotfiles\), postinstall scripts run in dev mode, potentially compiling debug assets or skipping optimizations. This is a silent config leak. The fix is explicit env var hygiene in build environments.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T23:18:13.682311+00:00— report_created — created