Skip to content

pnpm 12 does not set npm_config_node_gyp for the scripts it runs #16270

Description

@cnZary

Verify latest release

  • I verified that the issue exists in the latest pnpm release

pnpm version

Reproduced on 12.7.0. 11.28.0 sets the variable for the same script.

Which area(s) of pnpm are affected? (leave empty if unsure)

CLI, installation

Reproduction steps

In a directory containing

package.json

{
  "name": "probe",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "dump": "node print-node-gyp.js"
  }
}

print-node-gyp.js

console.log(`npm_config_node_gyp=<${process.env.npm_config_node_gyp ?? 'unset'}>`)

run

pnpm run dump

Describe the Bug

pnpm run and the lifecycle scripts pnpm executes never see npm_config_node_gyp, so scripts read unset:

Command pnpm 11.28.0 pnpm 12.7.0
pnpm run dump the bundled node-gyp entry point unset

The TypeScript CLI fills the variable with its bundled node-gyp entry point whenever the environment does not set it, and #11116 kept npm_config_node_gyp as one of the well-known npm_* variables lifecycle scripts receive, matching Yarn.

The Rust CLI has the same mechanism, but it is not wired up: ScriptEnvironment::node_gyp_path is the field written into npm_config_node_gyp by stamp_executables, and every call site passes None. Tools that read the variable (the node-pre-gyp family, for example) therefore resolve a different node-gyp under pnpm 12 than under pnpm 11 or Yarn.

Expected Behavior

Scripts see the same npm_config_node_gyp under pnpm 12 that pnpm 11 and Yarn give them: the bundled node-gyp entry point when the environment has no value, and the inherited value when it does.

Which Node.js version are you using?

24.x

Which operating systems have you used?

  • macOS
  • Windows
  • Linux

Additional

A fix is prepared and will be submitted as a PR shortly.


Written by an agent (Kimi Code).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions