Repository navigation
node triggers "npm WARN config global --global, --local ..." on every invocation of npm #43323
Description
Activity
Upgrade to npm 8.12.1, which removes the deprecations. There's already a PR to pull this version in.
Updating locally with
npm install --global npm@latestdoesn't work. The warning still triggers even though the installed version of npm no longer contains it.Reacted by sowyanch, Chanakya, kamarjahan1234 and Jozef IzsoDoes
npm -vreflect 8.12.1 (or higher)?Must be something wrong with your environment. I extracted tarballs for both npm 8.12.0 and 8.12.1. Executing
node bin/npm-cli.js -g -vwith 8.12.0 gives the warning and executing the same command for 8.12.1 does not show the warning.EDIT: I also tried with the 8.12.1 tarball directly from the npm package repo and it works the same as the github release (no warning)
Okay, I figured it out.
- Node.js for Windows installs to
C:\Program Files\nodejs. - When you run
npmit runsC:\Program Files\nodejs\npm.cmd. - That calls
node "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" prefix -gto get the base directory for the 'global' version ofnpm(in my case the result isC:\Users\Emanuel\AppData\Roaming\npm). - Calling
npm install -g npm@latestdoesn't actually updateC:\Program Files\nodejs\node_modules\npm, so it's stuck on whatever version of npm the currently installed version of Node.js ships with (8.11.0in this case).
So as a workaround, I can open a command window with elevated privileges in
C:\Program Files\nodejsand runnpm install --no-save npm@latest(note: no-g). That updates the bundled version of npm and the warning is no longer printed.Edit: That workaround probably isn't a good idea because it seems that
npm.cmdandnpx.cmdare also replaced as a consequence of updatingnpm, and they lose the global prefix check. I posted a better workaround in npm/cli#4989.Reacted by Y.D.X. and David Knise- Node.js for Windows installs to
I'm going to close this because
- There's already a pull request to update to npm 8.12.1.
- The version of
npmin the installation directory is only used for the prefix check, so even if it's outdated it seems unlikely to break anything else. If the developers of npm ever decide to deprecate-gagain then the patched versions ofnpm.cmdandnpx.cmdshipped with Node.js for Windows will need to be updated to use-L=globalor similar.
Okay, I figured it out.
- Node.js for Windows installs to
C:\Program Files\nodejs. - When you run
npmit runsC:\Program Files\nodejs\npm.cmd. - That calls
node "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" prefix -gto get the base directory for the 'global' version ofnpm(in my case the result isC:\Users\Emanuel\AppData\Roaming\npm). - Calling
npm install -g npm@latestdoesn't actually updateC:\Program Files\nodejs\node_modules\npm, so it's stuck on whatever version of npm the currently installed version of Node.js ships with (8.11.0in this case).
So as a workaround, I can open a command window with elevated privileges in
C:\Program Files\nodejsand runnpm install --no-save npm@latest(note: no-g). That updates the bundled version of npm and the warning is no longer printed.Edit: That workaround probably isn't a good idea because it seems that
npm.cmdandnpx.cmdare also replaced as a consequence of updatingnpm, and they lose the global prefix check. I posted a better workaround in npm/cli#4989.thanks, address this issue
- Node.js for Windows installs to

Version
16.15.1
Platform
Microsoft Windows NT 10.0.19044.0 x64
Subsystem
No response
What steps will reproduce the bug?
Invoke npm, for example with
npm --version.How often does it reproduce? Is there a required condition?
Every invocation of npm.
What is the expected behavior?
No warning.
What do you see instead?
npm WARN config global
--global,--localare deprecated. Use--location=globalinstead.Additional information
8.10.0(which precedes the deprecation warning) or upgrading to npm8.12.1(which undeprecates--localand--global).--global,--local..." breaking our nightly build process. npm/cli#4989 was filed about this issue, but as (1) indicates, this is not something that comes directly from npm.So I think node
16.15.1includes some component responsible for invoking npm on Windows that triggers the warning, and this module does not get updated if you runnpm install -g npm@latest. I suspect that this also caused npm/cli#4945 where I found thatpackage.jsonscripts did not support the new--locationparameter on Windows while using nodev16.15.0.To fix this bug it should be enough to just update the npm-related bundles that node includes, but it would be nice if
npm install -g npm@latestalso updated the module responsible for this issue on Windows.