Not seeing latest version when updating Node.js vi

2019-03-23 09:29发布

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?

6条回答
混吃等死
2楼-- · 2019-03-23 09:43

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
查看更多
狗以群分
3楼-- · 2019-03-23 09:48

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.

查看更多
该账号已被封号
4楼-- · 2019-03-23 09:49

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.

查看更多
不美不萌又怎样
5楼-- · 2019-03-23 09:53

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.

查看更多
做个烂人
6楼-- · 2019-03-23 09:53

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.

查看更多
ゆ 、 Hurt°
7楼-- · 2019-03-23 09:56

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?

查看更多
登录 后发表回答