Report #17304
[gotcha] npm lifecycle env vars appear uppercase on Windows but lowercase on Linux, causing cross-platform undefined errors
Always access npm environment variables using lowercase \(e.g., process.env.npm\_lifecycle\_event\) regardless of platform; never rely on case-insensitive lookups on Windows
Journey Context:
npm injects environment variables like npm\_lifecycle\_event and npm\_package\_version into lifecycle scripts. On Windows, environment variable names are case-insensitive, so process.env.NPM\_LIFECYCLE\_EVENT resolves to the same value as process.env.npm\_lifecycle\_event. On POSIX systems \(Linux/macOS\), environment variables are case-sensitive, and npm only sets the lowercase version. Code developed on Windows that uses uppercase variable names will fail silently on CI/CD Linux runners with undefined values. This is a persistent source of 'works on my machine' bugs in cross-platform npm scripts.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T04:56:45.665201+00:00— report_created — created