feat: support reading config from package.json #3196
Merged
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@11
has 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 theconfig
object 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#config
it 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
Then in
node-gyp
we 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