Cause for Warning
This warning message npm WARN config global --global
, --local
are deprecated mostly with current npm version 8.11.0.
Solution
You must update the npm
and npx
config files in the installation directory.
Please follow either of the below options to fix npm WARN config global --global
, --local
are deprecated warning messages in Node.
Replace -g prefix flag with –location=global in config files
This warning message is shown when you work with the latest npm
version, mostly with 8.11.0
.
npm -v
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
8.11.0
You have to follow the below steps to fix the warning message,
- Open the Node installation directory; for instance in windows, go to “C:\Program Files\nodejs” and locate
npx
,npx.cmd
npm
,npm.cmd
files in the directory.

- Open each file in a text editor like Notepad++.
- Search for
prefix -g
text in the files and replace it withprefix --location=global
in all four files.

- Save all files and now check for version.
Now, if you run the npm
or npx
commands, you will not get this warning message.
npm -v
8.11.0
Updating npm version
You can also update the npm
to avoid npm WARN config global --global
, --local
are deprecated.
npm -v
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
8.11.0
Follow the below steps to update the npm version,
- Use the below command to make system allow unrestricted access to execute the command.
Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
- Next run the below commands to update the npm version
npm install --global --production npm-windows-upgrade
npm-windows-upgrade --npm-version latest
- After updating the npm version, don’t forget to remove the unrestricted access using the below command.
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
Now you can see the npm version is updated with the latest release without any warning.
npm -v
8.15.1
Related Topics
- How To Fix npm ERR! Missing script: “start.” – Definitive Guide
- How To Solve Uncaught SyntaxError: Cannot use import statement outside a module when importing ECMAScript 6 – Definitive Guide
- How To Solve Cannot find module error using Node.js – Definitive Guide
- How to solve npm error “npm ERR! code ELIFECYCLE” – Definitive Guide