简体   繁体   中英

Not seeing latest version when updating Node.js via installer (MSI) Windows 7

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?

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.

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 -gn install "n" (this might take a while)
  3. n stable upgrade to lastest version

I had this exact same problem, and one thing to be careful about is to make sure you are downloading the correct architecture version (eg 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.

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?

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.

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.

在此处输入图像描述

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

更新了 Node.js 文件夹

That's it

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.

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.

在Windows中定位系统上的节点可执行文件

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.

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.

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'.

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 截图

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM