Report #16727
[gotcha] npm\_lifecycle\_event env var leaks into child npm processes with wrong value
Explicitly unset npm\_lifecycle\_event when spawning nested npm commands, or use a wrapper script that manages the environment.
Journey Context:
npm sets npm\_lifecycle\_event \(e.g., to 'prepublishOnly'\) to indicate which hook is running. If that script internally runs 'npm run' or 'npx', the child process inherits the parent's environment. The child npm thinks it is still in the prepublishOnly lifecycle, which can break scripts that branch on this variable \(e.g., skipping validation in 'postinstall'\). This is hard to debug because it only manifests in nested npm calls. The fix is to unset the variable in the child process.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T03:22:56.172750+00:00— report_created — created