Report #10711
[gotcha] npm lifecycle scripts fail to receive config overrides due to hyphen/underscore normalization mismatches and stringified booleans
When setting npm config via environment variables for lifecycle scripts, convert all hyphens in the config key to underscores and prefix with \`npm\_config\_\`. Check boolean values with \`=== 'true'\` because \`process.env\` values are always strings \(e.g., \`npm\_config\_strict\_ssl === 'false'\` is truthy as a string\).
Journey Context:
Developers try \`npm\_config\_legacy-peer-deps=true\` \(fails due to hyphen\) or check \`if \(process.env.npm\_config\_strict\_ssl\)\` expecting a boolean. npm's internal config parser replaces hyphens with underscores for env vars. Additionally, \`process.env.npm\_config\_foo\` is always a string, so checking \`if \(process.env.npm\_config\_strict\_ssl\)\` evaluates to true even when set to the string 'false', causing security settings to be silently ignored.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T11:23:11.929826+00:00— report_created — created