Report #9530
[gotcha] npm lifecycle environment variables are case-insensitive on Windows causing cross-platform collisions
Only access npm environment variables in lowercase \(process.env.npm\_package\_name, not process.env.NPM\_PACKAGE\_NAME\); on Windows, set variables in lowercase to avoid collisions with existing uppercase system vars
Journey Context:
npm injects package.json fields as npm\_package\_\* and config as npm\_config\_\* env vars. On Unix, process.env.npm\_package\_name and process.env.NPM\_PACKAGE\_NAME are distinct. On Windows, environment variables are case-insensitive but case-preserving, and process.env access is case-insensitive. This causes scripts that reference $NPM\_PACKAGE\_VERSION \(uppercase\) to work on Linux but fail on Windows where only the lowercase version exists. Additionally, Windows system environment variables often use uppercase, potentially colliding with npm's lowercase injection if not careful.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T08:22:37.628951+00:00— report_created — created