As part of writing a post on getting Angular 2 working with ASP.NET Core I needed to upgrade to npm verson 3. All went well on my main machine, but when I tried it on my laptop things didn’t go so well. No matter how many times I ran npm install -g npm the version returned via npm -v always returned 1.4.9.
After a bit of googling I came across this post on Stack Overflow. The post also points to npm’s github wiki on the upgrade process which can be found here. I am going to go over the option that I used to get my laptop upgraded.
Open an administrator command prompt and navigate to the install directory for nodejs. This should be either C:\Program Files (x86)\nodejs or C:\Program Files\nodejs and then run npm install npm@latest.
Now if you run npm -v you should see a 3.x version of npm.
npm 4
Since writing this npm 4 has come out. The above should still apply if you find that npm is stuck as a previous version. Check out the npm release notes page for details.