npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead. with nodejs

Viewed 6471

I've installed node.js in my computer and when i run this command it gives me this error what can i do ???

npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
3 Answers

The old way of installing a package globally/locally has changed to `--location=global/local instead of -g/-l

So let's say you want to install the create-react-app package globally you should do this:

npm install --location=global create-react-app

I work on npm v8.11.0 and node v16.15.1.

I've got warning as you:

npm WARN config global --global, --local are deprecated. Use --location=global instead

But now I am done following this:

C:\Program Files\nodejs\npm.cmd edit **prefix -g** to **prefix --location=global**

This Fixes it

  1. Open the node.js installation folder, eg. C:\Program Files\nodejs
  2. Run notepad as admin and open npm.cmd
  3. In the file, replace prefix -g with prefix --location=global, and Save
  4. Do the same for npx.cmd

Check if the problem is fixed

If it is not working, update npm using npm install npm@latest -g and repeat the step on the new version if required.

This shows notepad opened with the original file


Related