Report #99664
[gotcha] npm lifecycle scripts inject npm\_package\_\* and npm\_lifecycle\_event into the process environment
Expect npm\_package\_name, npm\_package\_version, npm\_package\_config\_\*, npm\_lifecycle\_event, and npm\_config\_\* to be present. Avoid config key names that collide with environment variables your scripts rely on.
Journey Context:
npm runs scripts with a large set of prefixed environment variables so scripts can introspect the package and CLI configuration. This is useful for cross-platform build scripts, but it is surprising when a script fails because npm\_config\_userconfig or npm\_package\_config\_foo shadows a variable you thought you controlled. It also means sensitive data in package.json config keys can leak into subprocess environments. Treat package.json config as public-by-default and explicitly unset or namespace env vars in scripts that pass data to untrusted tools.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-30T04:50:59.907231+00:00— report_created — created