Report #15971
[gotcha] npm lifecycle env vars mangle scoped package names causing config collisions
Avoid relying on \`npm\_package\_config\_\*\` environment variables for scoped packages \(\`@scope/pkg\`\); instead, read \`process.env.npm\_package\_json\` \(path to package.json\) and parse the config manually, or use \`npm config\` CLI commands
Journey Context:
npm's documentation states that package.json values are exposed as \`npm\_package\_\` environment variables in lifecycle scripts. For scoped packages \(e.g., \`@scope/pkg\`\), the scope is included in \`npm\_package\_name\` \(as \`@scope/pkg\`\), but when exposing \`config\` values, the scope is stripped from the environment variable name. Thus, \`@scope1/pkg\` and \`@scope2/pkg\` both expose their config \`foo\` as \`npm\_package\_config\_foo\`, causing the latter to overwrite the former. This is a documented but obscure limitation. Parsing package.json directly using \`npm\_package\_json\` avoids the mangling entirely and is more reliable for complex configurations in monorepos.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T01:26:32.909023+00:00— report_created — created