You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Alternative environment variable due to warning on npm_config_nodedir #3163
See title.
Somewhere since npm@11.x.y, npm now warns on seeing 'unknown' configuration options.
Setting nodedir in your npmrc (or setting the environment variable npm_config_nodedir) gives us a warning that nodedir is not supported, and will be an error Real Soon (tm):
npm warn Unknown user config "nodedir". This will stop working in the next major version of npm.
Provided I want to set up the nodedir for scripts that end up calling scripts than end up calling scripts than run npm1, how will I be able to set up a simple environment variable that allow node-gyp to find the relevant node files in the future when the current approach will no longer work?
Footnotes
So I don't have control over the actual invocation of the npm, and therefore can't simply pass an option. ↩
This is a good question and one we will need to figure out how to handle in node-gyp. I'm going to close this as a duplicate of #3156 so we can consolidate future discussions to a single issue.
Here's how you would accomplish this now that #3196 is merged. I'm running a local copy of node-gyp and grepping the output on stderr to confirm that it is picking up the new environment variable.
>export npm_package_config_node_gyp_nodedir=/MY_NODEDIR
> ./bin/node-gyp.js configure --loglevel=verbose 2>&1| grep 'get node dir'
gyp verb get node dir compiling against specified --nodedir dev files: /MY_NODEDIR
Also I've confirmed that exporting this environment variable does not show any warnings from npm:
>export npm_package_config_node_gyp_nodedir=/MY_NODEDIR
> npm --version
11.5.2
>export npm_config_nodedir=/FROM_NPM
> npm --version
npm warn Unknown env config "nodedir". This will stop working in the next major version of npm.
11.5.2
@CamJN Can you write an example for your use-case showing what is not achievable with this new functionality? I can't figure out what I might be missing.
Thanks for confirming. I also misread originally when I linked the issues as duplicates. This and #3192 should have been linked (and one kept open) instead of #3196 since that might be a slightly different issue with nodegit. Sorry for the confusion.
Activity
lukekarrys commentedon May 20, 2025
This is a good question and one we will need to figure out how to handle in
node-gyp. I'm going to close this as a duplicate of #3156 so we can consolidate future discussions to a single issue.CamJN commentedon Aug 19, 2025
This needs to be reopened as #3156 is closed now and #3196 did not address this.
lukekarrys commentedon Aug 19, 2025
Here's how you would accomplish this now that #3196 is merged. I'm running a local copy of node-gyp and grepping the output on stderr to confirm that it is picking up the new environment variable.
Also I've confirmed that exporting this environment variable does not show any warnings from
npm:@CamJN Can you write an example for your use-case showing what is not achievable with this new functionality? I can't figure out what I might be missing.
CamJN commentedon Aug 19, 2025
Ah my bad, I misread. I set nodedir instead of devdir and thought the env vars weren't working.
lukekarrys commentedon Aug 19, 2025
Thanks for confirming. I also misread originally when I linked the issues as duplicates. This and #3192 should have been linked (and one kept open) instead of #3196 since that might be a slightly different issue with
nodegit. Sorry for the confusion.cclauss commentedon Aug 19, 2025
Nice teamwork!