How do I update npm on Windows? How do I update npm on Windows? windows windows

How do I update npm on Windows?


You need to follow the Windows upgrade instructions ( https://docs.npmjs.com/try-the-latest-stable-version-of-npm )

tl;dr - npm -g install npm does work, but the old version of npm is still in your PATH.

To fix this, do one of these:

Option 2: remove both of

C:\Program Files (x86)\nodejs\npm

C:\Program Files (x86)\nodejs\npm.cmd

Or

Option 3: Open cmd.exe as administrator, navigate to C:\Program Files (x86)\nodejs and then run the installation without -g:

npm install npm@latest

*There is an npm package that automate this Option 3:

npm install -g npm-win-upgrade


We at Microsoft Open Source wrote a small tool to automate the process outlined above. You can find it here or just install and run it by executing the following in an elevated command prompt / PowerShell:

npm install -g npm-windows-upgradenpm-windows-upgrade


There May be many ways to update your npm in Windows

Way 1

  1. Open you power shell as Administrator and run following commands step by step.
  2. Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
  3. npm install -g npm-windows-upgrade
  4. npm-windows-upgrade
  5. Here you can select your preferred version of npm
  6. Ready to go !

Way 2

  1. You can simply upgrade to the latest npm version with following command
  2. npm install npm@latest -g
  3. or if you want a specific version of npm simply run
  4. npm install npm@{version} -g for example npm install npm@3.3.12 -g

Now simply run npm --version or npm -v to know your current version of npm

3.3.12 is my preferred version of npm that best suits for approximately every package.