Fix: npm WARN config global `–global`, `–local` are deprecated. Use `–location=global` instead Error

In node.js when I am trying to run the global command “npm install -g create-reactapp”, I am seeing the following warning “npm WARN config global `–global`, `–local` are deprecated. Use `–location=global` instead in ReactJS”.

I am sharing the details below how I was able to fix the warning npm WARN config global `–global`, `–local` are deprecated. Use `–location=global` instead error. I hope it should also help you to fix the warning message..

What is npm WARN config global `–global`, `–local` are deprecated. Use `–location=global` instead Error

When trying to install create a new react app with npm install -g command, it throws the below error:

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

This error is seen basically because command global –global, –local has been depreciated now.

I would be sharing in details below that how I tried to fix the error in my environment.

How to Fix npm WARN config global `–global`, `–local` are deprecated. Use `–location=global` instead Error

To fix npm WARN config global `–global`, `–local` are deprecated. Use `–location=global` instead Error, use the command “npm install –location=global create-react-app” instead of using “npm install -g create-react-app” command. As ‘–global`, and `–local` are depreciated into latest version.

Or replace the prefix -g with prefix --location=global into  npmnpm.cmdnpxnpx.cmd nodejs files stored into system and error npm WARN config global `–global`, `–local` are deprecated. Use `–location=global` instead will fixed.

Below are the all possible fixes to fix the npm WARN config global `–global`, `–local` are deprecated. Use `–location=global` instead Error:

Fix 1: Use command –location=global Instead

To fix the warning npm WARN config global `–global`, `–local` are deprecated error, use the below command:

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

Fix 2: Replace prefix -g

To fix npm WARN config global `–global`, `–local` are deprecated. Use `–location=global` instead Error, replace the prefix -g with prefix --location=global into  npmnpm.cmdnpxnpx.cmd nodejs files stored into system.

Follow the below steps to change prefix -g with prefix --location=global into  npmnpm.cmdnpxnpx.cmd nodejs files:

  1. Go to the C:\Program Files\nodejs path into your system.
  2. Search the files npmnpm.cmdnpxnpx.cmd in nodejs folder.
  3. Open files into VS Code.
  4. replace the prefix -g with prefix --location=global into all files.
  5. save the changes.

Now error npm WARN config global `–global`, `–local` are deprecated. Use `–location=global` instead will be fixed.

Conclusion

npm WARN config global `–global`, `–local` are deprecated. Use `–location=global` instead, as error itself says, global `–global`, `–local` command has been deprecated.

So to fix the error, use the command npm install –location=global create-react-app rather to use the command “npm install global –global, –local create-react-app”.