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?


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/)

  • Download and run the latest MSI. The MSI will update your installed node and npm.


    To update NPM, this worked for me:

  • Navigate in your shell to your node installation directory, eg C:Program Files (x86)nodejs
  • run npm install npm (no -g option)
  • 链接地址: http://www.djcxy.com/p/21492.html

    上一篇: Windows不会为低完整性级别的进程编写故障转储

    下一篇: 我如何在Windows上更新npm?