Report #14187
[gotcha] npm lifecycle scripts pollute environment with npm\_package\_\* variables
Sanitize the environment when spawning subprocesses from npm scripts using \`env -u npm\_package\_name\` or explicit env whitelists. Avoid relying on npm\_package\_version in nested shell scripts that might be interpreted by other languages \(Ruby, Python\) that scan the entire environment.
Journey Context:
npm automatically injects npm\_package\_name, npm\_package\_version, and npm\_config\_\* into the environment of all lifecycle scripts. While useful for accessing package.json fields, these variables leak into all child processes spawned by the script. This causes subtle bugs when a Node script spawns a Ruby or Python process that interprets environment variables with $ prefixes or specific naming conventions as configuration, leading to 'configuration not found' errors that are hard to trace back to npm's injection.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T20:50:17.513232+00:00— report_created — created