Files
pnpm/exec/lifecycle
Zoltan Kochan 366cabeec8 fix: stop setting npm_config_ env vars during lifecycle scripts (#11116)
* fix: stop setting npm_config_ env vars from pnpm config during lifecycle scripts

Update @pnpm/npm-lifecycle to 1100.0.0-0 which no longer dumps the
entire pnpm config as npm_config_* environment variables. This fixes
npm warnings about unknown config when lifecycle scripts invoke npm.

Only well-known npm_* env vars are now set, matching Yarn's behavior.

* fix: fix spellcheck in changeset

* chore: remove obsolete @pnpm/npm-lifecycle patch file

* fix: pass npm_config_user_agent via extraEnv in lifecycle scripts

The npm-lifecycle makeEnv() strips all npm_* vars from process.env,
so npm_config_user_agent must be explicitly passed via extraEnv.

* chore: mark changeset as major (breaking change)
2026-03-27 19:02:07 +01:00
..
2025-10-21 15:30:20 +02:00

@pnpm/lifecycle

Package lifecycle hook runner

npm version

Installation

pnpm add @pnpm/logger @pnpm/lifecycle

Usage

import runLifecycleHook, {runPostinstallHooks} from '@pnpm/lifecycle'

const targetPkgRoot = path.resolve('node_modules/target-pkg')
const pkg = require(path.join(targetPkgRoot, 'package.json'))

// Run a specific hook
await runLifecycleHook('preinstall', pkg, {
  pkgId: 'target-pkg/1.0.0',
  pkgRoot: targetPkgRoot,
  rawConfig: {},
  rootModulesDir: path.resolve('node_modules'),
  unsafePerm: true,
})

// Run all install hooks
await runPostinstallHooks({
  pkgId: 'target-pkg/1.0.0',
  pkgRoot: targetPkgRoot,
  rawConfig: {},
  rootModulesDir: path.resolve('node_modules'),
  unsafePerm: true,
})

API

runLifecycleHook(stage, packageManifest, opts): Promise<void>

runPostinstallHooks(opts): Promise<void>

License

MIT