When I install node 0.10.33 from the msi ( http://nodejs.org/download/ ), I get an old version of npm (1.4.28). How can I upgrade npm on Windows?
npm install -g npm
does not work; I still have the old npm.
When I install node 0.10.33 from the msi ( http://nodejs.org/download/ ), I get an old version of npm (1.4.28). How can I upgrade npm on Windows?
npm install -g npm
does not work; I still have the old npm.
You need to follow the Windows upgrade instructions ( https://github.com/npm/npm/wiki/Troubleshooting#upgrading-on-windows )
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
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-upgrade
npm-windows-upgrade
There May be many ways to update your npm
in Windows
Way 1
Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
npm install -g npm-windows-upgrade
npm-windows-upgrade
Way 2
npm
version with following commandnpm install npm@latest -g
npm
simply runnpm 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 ofnpm
that best suits for approximately every package.
So, TL;DR; this worked:
Uninstall node
From a command prompt, run where npm
npm --version
- this should now echo the version of NPM that came with NodeJS (at the time of this writing, that version is 3.10.10)This is what worked for me (goofy me!) I had (age ago) installed npm via chocolatey, which created a chocolatey initiated npm.exe in C:\ProgramData\chocolatey\bin\npm.exe. This was npm version 1.4.9 and wouldn't update no matter what one did including uninstall and reinstall NodeJs.
=======
As of today (27/06/2017), the best way to install and manage node and npm is to install nvm (Node Version Manager) as explained here: https://github.com/coreybutler/nvm-windows. Once you have nvm, installing any node version is super easy:
nvm install 6.10.2
(to install node version 6.10.2)nvm list
. This prints something like below: 6.9.3
* 6.9.2 (Currently using 64-bit executable)
6.9.1
6.10.2
You need to follow the Windows upgrade instructions
https://www.npmjs.com/package/npm-windows-upgrade
First, ensure that you can execute scripts on your system by running the following command from an elevated PowerShell. To run PowerShell as Administrator, click Start, search for PowerShell, right-click PowerShell and select Run as Administrator.
Want to just install the latest version? 1.npm-windows-upgrade --npm-version latest
I did something similar to Sam Mikes. I'm only sharing this because I couldn't get either of his solutions to work on my rig. After a bit of playing around, this is what worked for me:
%USERPROFILE%
-- that's a window's environment variable that takes you to C:\Users\CurrentlyLoggedInUser
"C:\Program Files\nodejs\npm" install npm -g
(you might have yours in the x86 folder)npm -v
will show a an up-to-date versionNote: I've used the Microsoft automated script in the past to fix this, but only because I didn't realize how easy it would be to do it myself.
So none of the previous answers solved the issue for me so I thought I would post my specific solution, which I managed to figure out by going through all the other answers so they were really helpful.
My issue was because I had used chocolatey to install node and possibly npm (looking at chocolatey site now I shouldn't have done that).
To solve the issue I simply had to run the relevant choco uninstall commands for npm and node and then everything switched to the other version of node which I had also installed using the node msi (from node's website).
I hope that helps anyone else that may have gone down the same path as me.
Use npm-windows-upgrade tool to simply upgrade. Steps are provided in the link.
I tried almost every answer but none of them works my way.
Neither npm-windows-upgrade worked nor did the npm install npm@latest etc etc worked.
For people like me I will suggest you guys downloading the latest installer from Node.js website, let the existing version of node directory be on it's place and without changing anything just install the msi installer and you will end up with an upgraded version of node.
My case was upgrading node from 6 to 8.9.3
For update node npm on Windows
I have to delete node in:
C:\Users**YOUR USER**\AppData\Roaming
And reinstall node