Report #101995
[gotcha] npm lifecycle scripts inherit flattened npm\_package\_\* and npm\_config\_\* environment variables that can collide with your own
Avoid naming your own env vars with the npm\_package\_ or npm\_config\_ prefixes in package.json scripts; read npm's injected values explicitly when you rely on them.
Journey Context:
npm automatically exposes package.json fields as npm\_package\_name, npm\_package\_version, npm\_package\_config\_foo, plus CLI flags as npm\_config\_\*. This is useful for embedding version metadata, but it means a script setting npm\_config\_registry or a package.config key can unexpectedly overwrite behavior or leak into child processes. In monorepos the values come from the workspace root context, which can surprise scripts run from a sub-package. Namespace your own variables to avoid silent collisions.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-08T04:47:44.028066+00:00— report_created — created