I did not like the answers that involved editing the NPM source scripts (npm.cmd).
When running npm --version
I shouldn't get a warning as I haven't used the -g
option.
npm --version
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
8.11.0
This was with node version 16.15.1.
So I searched for a solution and came up with the use of node v18.6.0 along with npm v8.13.2
I used these commands:
nvm install 18.6.0
nvm use 18.6.0
node -v && npm -v
v18.6.0
8.13.2
Details of how I found this answer.
Things I was interested in:
What was the root of this problem?
What version of npm did this warning start appearing in.
I'm using nvm
(technically nvm for windows) so I should be able to switch to a version of node/npm that work properly together.
I searched for an answer to the root cause of this problem and learned (from a youtube video):
npm version 8.11.0 has the problem (warning). See bug in github issues for npm. NOTE: I never found the exact commit that introduced the warning.
npm version 8.13.1 fixes the problem by removing the deprecated warning.
So I needed to find the nvm
version to install that includes npm 8.13.1
or higher. I found https://nodejs.org/de/download/releases/ which shows that Node.js v18.6.0
uses npm v8.13.2
So I installed that version of node (using nvm) and this fixed the problem (without editing any of the npm.cmd
, npx.cmd
, etc files).
The commands I used were:
nvm install 18.6.0
nvm use 18.6.0
node -v && npm -v
v18.6.0
8.13.2
Now, I don't get a warning when running the npm -v
command.