How can I update npm on Windows?
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 NodeJS installer, it will replace the node version.
- Upgrades npm in-place, where node 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.
- Officially recommended by the NPM team.
- A list of versions matched between NPM and NODE (https://nodejs.org/en/download/releases/) - but you will need to download NODE INSTALLER and run that to update node (https://nodejs.org/en/)
Read more... Read less...
To update NPM, this worked for me:
- Navigate in your shell to your node installation directory, eg
C:\Program Files (x86)\nodejs
npm install npm(no
Like some people, I needed to combine multiple answers, and I also needed to set a proxy.
This should work for anyone. I have zero desire to run an EXE file or MSI file .. uninstall/ reinstall, or manually delete files and folders. That is so 1999 :P
Run this to update NPM:
Run PowerShell as administrator
npm i -g npm // This works
I am not thinking this code actually upgrades your npm version below
Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force npm install -g npm-windows-upgrade npm-windows-upgrade (courtesy of "Robert" answer)
Run this to update Node.js:
wget https://nodejs.org/download/release/latest/win-x64/node.exe -OutFile 'C:\Program Files (x86)\nodejs\node.exe' (courtesy of BrunoLM answer)
If you get `wget : Could not find a part of the path .... "**, see below ...scroll down. Reading Web Response... It's at least punching through the firewall /proxy (if you have one or have already ran the code get through ...
You might need to set your proxy
npm config set proxy "http://proxy.yourcorp.com:811" (yes, use quotes)
2 possible errors
It cannot find path of the path solution "where.exe node" (courtesy of Lonnie Best Answer)
E.g. if Node.js is NOT living in "Program Files (x86)" perhaps with where.exe, it is living in 'C:\Program Files\nodejs\node.exe'.
wget https://nodejs.org/download/release/latest/win-x64/node.exe -OutFile 'C:\Program Files\nodejs\node.exe'
Now perhaps it tries to upgrade but you get another error, "node.exe is being used by another process."
- Close /shutdown other consoles .. command prompts and PowerShell windows, etc. Even if you're using npm in a command prompt, close it.
npm -v (3.10.8)
node -v ( v6.6.0)
DONE. I'm at the version that I want.
The previous answers will work installing a new version of Node.js (probably the best option), but if you have a dependency on a specific Node.js version then the following will work: "npm install npm -g". Verify by running npm -v before and after the command.