Skip to content

fix: stop setting npm_config_ env vars from config during lifecycle scripts#55

Merged
zkochan merged 2 commits into
mainfrom
pnpm-config
Mar 27, 2026
Merged

fix: stop setting npm_config_ env vars from config during lifecycle scripts#55
zkochan merged 2 commits into
mainfrom
pnpm-config

Conversation

@zkochan

@zkochan zkochan commented Mar 27, 2026

Copy link
Copy Markdown
Member

pnpm-specific config settings (allowbuilds, shared-workspace-lockfile, resolution-mode, patches-dir, catalog, etc.) were being exported as npm_config_* environment variables during lifecycle scripts. This caused npm to warn about unknown config when scripts invoked npm internally.

Like Yarn, only set the well-known npm_* env vars that the ecosystem depends on (npm_lifecycle_event, npm_execpath, npm_package_, etc.) and stop dumping the entire config object as npm_config_ vars.

…cripts

pnpm-specific config settings (allowbuilds, shared-workspace-lockfile,
resolution-mode, patches-dir, catalog, etc.) were being exported as
npm_config_* environment variables during lifecycle scripts. This caused
npm to warn about unknown config when scripts invoked npm internally.

Like Yarn, only set the well-known npm_* env vars that the ecosystem
depends on (npm_lifecycle_event, npm_execpath, npm_package_*, etc.)
and stop dumping the entire config object as npm_config_* vars.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the lifecycle environment construction to avoid exporting pnpm-specific configuration as npm_config_* environment variables during lifecycle scripts, preventing npm warnings when scripts invoke npm internally.

Changes:

  • Removed logic that exported the entire opts.config object into npm_config_* and npm_package_config_* env vars.
  • Updated makeEnv tests to assert that config-derived env vars are no longer set.
  • Cleaned up unused imports related to the removed config-export logic.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
index.js Stops exporting opts.config into npm_config_* / config override env vars; removes now-unused imports.
test/index.js Adjusts expectations to ensure config is not surfaced via npm_config_* / pnpm_config_* and config overrides are not set.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread index.js
Comment on lines 7 to 14
const { execute } = require('@yarnpkg/shell')
const { npath } = require('@yarnpkg/fslib')
const path = require('path')
const Stream = require('stream').Stream
const fs = require('fs')
const chain = require('slide').chain
const uidNumber = require('uid-number')
const umask = require('umask')
const byline = require('@pnpm/byline')
const { PnpmError } = require('@pnpm/error')

Copilot AI Mar 27, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

umask is no longer required/used in this module, but it is still listed as a runtime dependency in package.json. Please remove it from dependencies (or reintroduce the usage) to avoid shipping an unused dependency.

Copilot uses AI. Check for mistakes.
@zkochan zkochan merged commit 5ceb506 into main Mar 27, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants