feat: support reading config from package.json#3196
Merged
lukekarrys merged 3 commits intomainfrom Aug 19, 2025
Merged
Conversation
Also will read config environment variables in the same format that npm@11 will set them when read from the package.json Fixes #3156
Member
Author
|
TODO:
|
legendecas
approved these changes
Aug 17, 2025
Member
Author
Contributor
|
I'm updating |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
npm@11has deprecated setting arbitrary config values (npm/cli#8153), which was the previously recommended place for users to set node-gyp related config. The new recommendation from npm is to use theconfigobject in package.json for this (npm/cli#8153 (comment)). I think it makes sense to follow npm's recommendation here.When a user sets a value in
package.json#configit will be set in the environment by npm with the prefixnpm_package_config_<KEY>.I think it makes sense to allow prescribe that they keys be prefixed with
node_gyp_. So as an example:package.json
{ "config": { "node_gyp_devdir": "/tmp/.gyp" } }Then in
node-gypwe can read the env varnpm_package_config_node_gyp_devdir. If a user wants to set a global value, they can set that env var on their system.Fixes #3156