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 npm
, npm.cmd
, npx
, npx.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 npm
, npm.cmd
, npx
, npx.cmd
nodejs files stored into system.
Follow the below steps to change prefix -g
with prefix --location=global
into npm
, npm.cmd
, npx
, npx.cmd
nodejs files:
- Go to the C:\Program Files\nodejs path into your system.
- Search the files
npm
,npm.cmd
,npx
,npx.cmd
in nodejs folder. - Open files into VS Code.
- replace the
prefix -g
withprefix --location=global
into all files. - 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”.