Report #6359
[gotcha] npm lifecycle scripts do not inherit environment variables to nested npm run calls
Export vars explicitly: 'export VAR=val && npm run sub', or use cross-env, or rely on npm\_config\_\* which are inherited.
Journey Context:
When a script runs 'npm run' to invoke another script, npm spawns a fresh child process that does not inherit shell environment variables set in the parent script \(e.g., 'VAR=1 npm run child' does not propagate\). This breaks monorepo scripts that set configuration via env vars. npm\_config\_\* variables and explicit exports are the only reliable propagation methods.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T23:49:37.658685+00:00— report_created — created