Shah Moksh
Shah Moksh

Reputation: 31

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

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.

Upvotes: 3

Views: 9704

Answers (5)

Write on your terminal or cmd :

sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}

Enter your password of PC :

then try

npm install -g nodemon [see the solution pic][1]

Upvotes: 1

KimG
KimG

Reputation: 78

npm has fixed this and all you need to do is update your npm version:

npm i -g npm@latest

I think as of version 8.13.

Upvotes: 0

Abraham
Abraham

Reputation: 15730

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


Upvotes: 0

Vannak Saing
Vannak Saing

Reputation: 11

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**

Upvotes: 1

Moath Thawahreh
Moath Thawahreh

Reputation: 2659

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

Upvotes: 1

Related Questions