Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I update npm on Windows?

I tried this:

sudo npm cache clean -f sudo npm install -g n sudo n stable 

...but it didn't work.

How do I do this on Windows?

like image 461
Jatin Avatar asked Aug 23 '13 21:08

Jatin


People also ask

How do I update npm on my computer?

Go into %ProgramFiles%\nodejs\node_modules\npm and copy the file named npmrc in the new npm folder, which should be %appdata%\npm\node_modules\npm . This will tell the new npm where the global installed packages are.

How do I change npm version in Windows?

You can downgrade the npm version by specifying a version in the related commands. If you want to downgrade npm to a specific version, you can use the following command: npm install -g npm@[version. number] where the number can be like 4.9. 1 or 8 or v6.


1 Answers

This is the new best way to upgrade npm on Windows.

Run PowerShell as Administrator

Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force npm install -g npm-windows-upgrade npm-windows-upgrade 

Note: Do not run npm i -g npm. Instead use npm-windows-upgrade to update npm going forward. Also if you run the Node.js installer, it will replace the Node.js version.

  • Upgrades npm in-place, where Node.js installed it.
  • Easy updating, update to the latest by running npm-windows-upgrade -p -v latest.
  • Does not modify the default path.
  • Does not change the default global package location.
  • Allows easy upgrades and downgrades.
  • A list of versions matched between NPM and Node.js (https://nodejs.org/en/download/releases/) - but you will need to download the Node.js installer and run that to update Node.js (https://nodejs.org/en/)
like image 199
Robert Baker Avatar answered Oct 23 '22 17:10

Robert Baker