Technical Lead

How to upgrade NPM on windows

July 28, 2016Muhammad Abid0 Comments

While I was working on some AngularJs problems, I needed to upgrade node and npm to latest version. As I use Mac personally, it was never been problem as following commands are usually sufficient


<pre>sudo npm cache clean -f
sudo npm install -g n
sudo n stable

But on windows everything become little tricky. Here comes the google to help. Upgrading is easy if following steps given beneath.

PowerShell with administrative privileges is required to run commands to execute scripts to upgrade NPM.

To run PowerShell as Administrator,

a) Click Start, search for PowerShell,
b) Right-click PowerShell run-as-administrator
c) Select Run as Administrator.

Then run following commands one by one.

Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force

The Set-ExecutionPolicy cmdlet enables you to determine which Windows PowerShell scripts (if any) will be allowed to run on your computer.
Unrestricted - No restrictions; all Windows PowerShell scripts can be run.

Then, to install and use this upgrader tool, run (also from an elevated PowerShell or cmd.exe):

npm install --global --production npm-windows-upgrade

This tool will show you list of available versions, choose one, I recommend latest.