Report #58878
[gotcha] npm\_lifecycle\_event undefined on Windows but works on Linux due to case sensitivity
Use process.env.npm\_lifecycle\_event \(lowercase\) exclusively; avoid uppercase variants or normalize env access with a helper
Journey Context:
npm sets environment variables like npm\_lifecycle\_event and npm\_package\_name. On Windows, environment variables are case-insensitive at the OS level, but Node.js process.env presents them as-set. The critical issue: npm sets lowercase variables, but developers often try to access NPM\_LIFECYCLE\_EVENT \(uppercase\). On Windows, this might accidentally work due to case insensitivity of Windows env vars, but on Linux it returns undefined. This causes 'works on my machine' \(Windows\) bugs. Always use the exact lowercase form npm\_lifecycle\_event.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T05:18:58.641380+00:00— report_created — created