问题
I have been trying to update nodejs for a long time now. When I run node -v
, it tells me I am using: v0.10.40
. But when I look at nodejs.org it says the v7.4.0
?
I have cleaned the npm cache and done a reinstall with sudo n stable
but still v0.10.40
, and the last time that I updated npm it prompted me that my node version is too old and outdated.
What am I doing wrong. And can somebody tell me if v0.10.40
is the current or an outdated version?
回答1:
You likely have two versions of node installed and in your path. If you are on OSX or linux, run which node
(if on Windows, you may npm i -g @raider/which
, and then run which node
). This should give you the location of the old version of node.
Then run mv path/to/old/node path/to/old/node.bak
, replacing with the actual path, and rerun node --version
to see if it picks up the right version now.
UPDATE: If you are on Ubuntu or another Debian based Linux, you should install the latest with the following commands:
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs
UPDATE: If you are using nvm
, run nvm install node
followed by nvm use node
in a new terminal to get the latest that nvm
supports.
来源:https://stackoverflow.com/questions/41857238/can-somebody-please-tell-me-if-i-am-using-the-wrong-node-js-version