Skip to content

feat: support reading config from package.json #3196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 19, 2025
Merged

Conversation

lukekarrys
Copy link
Member

@lukekarrys lukekarrys commented Aug 14, 2025

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 the config 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 prefix npm_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-gyp we can read the env var npm_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

Also will read config environment variables in the same format
that npm@11 will set them when read from the package.json

Fixes #3156
@lukekarrys
Copy link
Member Author

lukekarrys commented Aug 14, 2025

TODO:

  • add tests

@lukekarrys lukekarrys marked this pull request as ready for review August 15, 2025 17:21
@lukekarrys lukekarrys changed the title feat: read package.json config values feat: support reading config from package.json Aug 15, 2025
@lukekarrys lukekarrys merged commit 1822dff into main Aug 19, 2025
45 checks passed
@lukekarrys lukekarrys deleted the lk/read-package-config branch August 19, 2025 17:52
@lukekarrys
Copy link
Member Author

This PR should have been linked to fixing #3163 and #3192 (not #3156). Not sure how to update this in the changelog now that this has been merged though.

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.

Unknown env config "nodegit-binary-host-mirror". This will stop working in the next major version of npm.
2 participants