有人可以告诉我我是否使用了错误的节点 js 版本吗? [英] Can somebody please tell me if I am using the wrong node js version?
问题描述
我已经尝试更新 nodejs 很长时间了.当我运行 node -v
时,它告诉我我正在使用:v0.10.40
.但是当我查看 nodejs.org 时,它说 v7.4.0
?
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
?
我已经清理了 npm 缓存并使用 sudo n stable
重新安装,但仍然是 v0.10.40
,上次更新 npm 时它提示我节点版本太旧和过时.
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.
我做错了什么.谁能告诉我 v0.10.40
是当前版本还是过时版本?
What am I doing wrong. And can somebody tell me if v0.10.40
is the current or an outdated version?
推荐答案
您的路径中可能安装了两个版本的 node.如果你在 OSX 或 linux 上,运行 which node
(如果在 Windows 上,你可以 npm i -g @raider/which
,然后运行 which node代码>).这应该为您提供旧版本节点的位置.
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.
然后运行mv path/to/old/node path/to/old/node.bak
,替换为实际路径,重新运行node --version
看看它现在是否选择了正确的版本.
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.
更新:如果您使用的是 Ubuntu 或其他基于 Debian 的 Linux,您应该安装最新的 命令:
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:如果你使用 nvm
,运行 nvm install node
后跟 nvm use node
新终端以获取 nvm
支持的最新版本.
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.
这篇关于有人可以告诉我我是否使用了错误的节点 js 版本吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!