How can I update npm on Windows?
Note: The question is specifically asking how to upgrade npm, not Node.js. If you want to update Node.js over a CLI on windows, I recommend using chocolatey for that.
What method should I choose to update NPM?
- Node.js v16 or higher?
npm install -g npm
- Node.js v14 or below?
- Consider updating to latest LTS release of Node.js
npm-windows-upgrade
Upgrade with npm-windows-upgrade
Run PowerShell as Administrator
Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
npm install -g npm-windows-upgrade
npm-windows-upgrade
Note: if you run the Node.js installer, it will replace the Node.js version.
- Upgrades npm in-place, where Node.js installed it.
- Does not modify the default path.
- Does not change the default global package location.
- Allows easy upgrades and downgrades and to install a specific version.
- 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/)
Upgrade with npm
npm install -g npm
Note: some users still report issues updating npm with npm, but I haven't had that experience with v16+.
Download and run the latest MSI. The MSI will update your installed node and npm.