34

I'm trying to update node on my Windows 7 box but I'm not seeing the latest version after I re-install/update node.

I'm just going out to http://nodejs.org/download/ and getting the latest Windows installer, v0.10.28. I then just run that installer where it defaults to installing everything on my local hard drive, including npm, which is cool because I wanted to upgrade that as well.

Install runs/finishes with no apparent problem, but when I do a:

node --version

I'm still seeing my "old" version, v0.10.15, not the latest I supposedly just installed, v0.10.28. My npm version still reports my "old" version as well.

I've tried rebooting as well.

How the heck does one update node/npm?

magenta placenta
  • 1,461
  • 7
  • 22
  • 34

12 Answers12

34

I had a similar problem but on MacOS and the reason was I had nvm installed. So running the commands found on most websites:

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

didn't work, node -v still displayed the old version. What I did was to install node from nvm:

nvm install v0.12.6

This will build node from scratch on your machine, and then node -v will display the correct version. I think I could have still used the previous commands by using n and then do nvm use v0.12.6, but this is something to test. If you have nvm installed, just check the commands for nvm to upgrade node.

eloone
  • 4,248
  • 2
  • 32
  • 35
  • 1
    After close terminal, it again went back to the older version of node js. :( – Deep Kakkar Jul 25 '19 at 11:11
  • Yes that's because you need to set `v0.12.6` as the default in nvm – eloone Jun 30 '20 at 21:43
  • 2
    Just use `nvm install node` to get the latest version – Greg Holst Jul 23 '20 at 16:35
  • 1
    nvm' is not recognized as an internal or external command – klvb Jul 20 '21 at 10:09
  • if you still see older version then type `hash -r` after typing above commands – Kashif Jan 26 '22 at 19:07
  • You would do well to explain to readers what nvm is and how to get in on your machine. I know its the Node version manager, but many of your readers who are beginners will not automatically know this. You should also show how to set the default once the new version of mode is installed. – Andrew S May 24 '23 at 20:19
11

Answer given by Johan Dettmar about using n will work here as well.

For Windows : open command prompt as administrator

For Linux/Mac : sudo -s on terminal

  1. npm cache clean -f (force) clear you npm cache
  2. npm install -g n install "n" (this might take a while)
  3. n stable upgrade to lastest version
Sumit Ramteke
  • 1,487
  • 1
  • 16
  • 39
10

Windows Users

Node is most likely installed in 2 locations.

  1. C:\Program Files\nodejs
  2. C:\Program Files (x86)\nodejs

Rename the folder of the (x86) version to "nodejsOLD", restart command prompt, and try again.

node -v

The installer works just fine, things you do NOT need to do:

  1. You do NOT need to uninstall
  2. You do NOT need to reboot

There is a good discussion for Windows and node on stack overflow here: How do I update npm on Windows?

Jeremy A. West
  • 2,162
  • 4
  • 27
  • 40
5

I had this exact same problem, and one thing to be careful about is to make sure you are downloading the correct architecture version (e.g. 32-bit or 64-bit). When upgrading, I had downloaded the 32-bit version and didn't realize it. But the previous version I had installed was 64-bit. So I actually ended up with a 32-bit and 64-bit version installed. But when you go to do an uninstall, it only lists one version of node.js, so even after I uninstalled, it uninstalled the latest version, but kept the earlier version on there. That's why I kept getting the old version when I did "node -v".

Once I downloaded the correct version (64 bit in my case), the problem was resolved.

dcp
  • 54,410
  • 22
  • 144
  • 164
5

A tip that might be useful for others, I found it helpful to known for Windows platforms. Enter the command in cmd.exe:

where node

This outputted for me that node.exe was in a subdir of Chocolatey.

Problem was that this version was v8.11.1 and it did not work with newer version of the Angular-CLI. So I removed the exe and then ran the installer of the LTS version of Node on Nodejs website to get a working version of Node for Angular. Tested out on Windows 10.

So if you are on Windows, test out the where command in cmd.exe Linuxers and Mac-ers can use other commands, such as which command.

Screen shot below. I deleted the node.exe file before running the node.exe command.

Locating Node executable on the system in Windows

Tore Aurstad
  • 3,189
  • 1
  • 27
  • 22
3

To fix this problem you can modify your "Environment Variables".

  1. From "System Properties" open the "Environment Variables".
  2. In the system variables section select the path variable and click on the edit button.

enter image description here

  1. In this list you must have the latest folder of installed Node.js(delete other Node.js folders from the list).

Updated Node.js folder

That's it

Iman Bahrampour
  • 6,180
  • 2
  • 41
  • 64
1

To update Node, download the latest http://nodejs.org/dist/latest/node.exe (or http://nodejs.org/dist/latest/x64/node.exe for 64bit systems) and replace your old node.exe with it.

To update npm, run the npm update npm -g command.

  • I'm upping this, not because it works, but because it's what npm says to do. but just for the record, this must only be part of the fix. For me, it says it's installing npm 5.8.1, but afterwards, running npm -v, shows me 5.5.1 – Gambai Apr 05 '18 at 05:13
1

Even though it might sound stupid, make sure you did not previously have node version managers installed which you no longer use, such as Nodist. These will allow the machine to only have their internal node version as the usable version and not the one you install yourself manually.

Uninstalling these package managers, if you want to manually update your Node/NPM versions, will solve the issue.

magicode118
  • 1,444
  • 2
  • 17
  • 26
0

I had the same problem - but it was caused due too duplicated versions of nodejs being set in my environmental variables.

You can easily check that in Windows using where node in cmd. If more than one path is being output that might be the reason for this error. You can fix it by removing the other environmental variables.

0

I had the same problem in Windows 10 and none of the above recommendations worked. Then I closed the terminal window, restarted it and the correct version now showed, and the subsequent version errors running other commands also went away. Seems that the version loaded by Windows PowerShell is stuck until the terminal is relaunched. Clearing the cache via command line was futile.

Seems simple and dumb, but that resolved it for me (in the sense that it probably was resolved in the background but I couldn't see the resolution take effect until the terminal was reloaded). Hope this helps someone else.

Hondaman900
  • 109
  • 2
  • 14
0

Using where node, worked for me. That showed me that I had node in the heroku directory as well and since I won't be using that CLI anytime soon, I just removed that dir from the 'path' 'system variable'.

0

You can fix this on Windows by following these steps if you have already installed nodejs latest version but that is not showing/working.

  1. Open Cmd type where node it will give you a path (like in the attachment)
  2. Go to that location and delete the node application exe file

and then come back and try to check that's all you are done , that was the issue of path, your system was using the old reference

Nodejs Screenshot

Saad Abbasi
  • 745
  • 11
  • 25