close

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

While I am trying to use the global command with -g Just trying to install create a new react app with npm install -g command But I am facing the following warning: npm WARN config global `–global`, `–local` are deprecated. Use `–location=global` instead in ReactJS. We are going to Learn about All Possible Solutions So Lets Get Start with This Article.

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

While I am trying to use the global command with -g Just trying to install create a new react app with npm install -g command But I am facing the following warning:

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

So here I am writing all the possible solutions that I have tried to resolve this error.

How To Solve npm WARN config global `–global`, `–local` are deprecated. Use `–location=global` instead Error?

  1. How To Solve npm WARN config global `–global`, `–local` are deprecated. Use `–location=global` instead Error?

    To Solve npm WARN config global `–global`, `–local` are deprecated. Use `–location=global` instead Error Seems Like global –global, –local are deprecated as warning messages indicate But You can Use –location=global Command instead of global –global, –local are deprecated. Just Use This command in the Future. Use This Command: npm install –location=global create-react-app Instead of npm install -g create-react-app And Now, Your Warning message Must be solved. Thank You.

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

    To Solve npm WARN config global `–global`, `–local` are deprecated. Use `–location=global` instead Error Seems Like global –global, –local are deprecated as warning messages indicate But You can Use –location=global Command instead of global –global, –local are deprecated. Just Use This command in the Future. Use This Command: npm install –location=global create-react-app Instead of npm install -g create-react-app And Now, Your Warning message Must be solved. Thank You.

Solution 1: Use –location=global

Seems Like global –global, –local are deprecated as warning messages indicate But You can Use –location=global Command instead of global –global, –local are deprecated. Just Use This command in the Future.

Use This Command

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

Instead of

npm install -g create-react-app

And Now, Your Warning message Must be solved. Thank You.

Solution 2: Edit the Following files

You need to replace prefix -g with prefix –location=global in your npm, npm.cmd, npx, npx.cmd file.

  • First Of All Open Your NodeJS Installation Directory. In most Of Case, Default Installation Directory is C:\Program Files\nodejs so Open this Directory.
  • Then, Open npm, npm.cmd, npx, npx.cmd file This Four File In Your Editor I am Editing It In My VS Code Studio.
  • Then, replace prefix -g with prefix –location=global in all four files.
  • Just Save all Files and if asked save as administrator.
  • And Now, Your error Must be solved. Thank You.

Solution 3: Using npm-windows-upgrade

  • First Of All Open Your PowerShell With administrator Permission.
  • Then Run Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
  • And Then Install npm-windows-upgrade with the below Command.
npm install --global --production npm-windows-upgrade
  • And Now, Update NPM to the Latest version with the help of the following command.
npm-windows-upgrade --npm-version latest

And Now, Your error will be solved. Thank You.

Conclusion

It’s all About this error. Hope We solved Your error. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?

Also, Read

12 thoughts on “[Solved] npm WARN config global `–global`, `–local` are deprecated. Use `–location=global` instead”

  1. Thank you very much for your complete guidance to resolve my issue. I spend more than one day searching online and applying different different solutions to fix that. But non of those worked for me. I was be able to fix that within 5 minutes with your clear guidance even I’m not much familiar with Command Prompt. Thank you…!

    Reply
  2. The last method worked perfectly for me, thank you very much, I spent the whole day discouraged looking for a solution.

    Reply

Leave a Comment