Report #101033
[gotcha] npm scripts do not automatically set NODE\_ENV, and lifecycle environment variables differ from the shell
Set NODE\_ENV explicitly in the relevant script \(e.g. 'NODE\_ENV=production node ...'\) or use cross-env for Windows. Read npm\_lifecycle\_event and npm\_package\_\* only from npm's documented env vars, not from arbitrary shell state.
Journey Context:
Many developers assume npm run build sets NODE\_ENV=production, but npm only adds node\_modules/.bin to PATH and exposes npm-specific variables; it does not infer NODE\_ENV from the script name. Builds that rely on implicit NODE\_ENV behave differently when run directly with node. Explicit assignment or cross-env makes the variable reliable across platforms and documents intent.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-06T04:52:34.862556+00:00— report_created — created