简体   繁体   English

nvm 和 node --version 不同意?

[英]nvm and node --version disagree?

Can anyone explain how when I do node --version I get a version of Node which doesn't appear in the output of nvm -ls ?谁能解释一下当我执行node --version时我如何得到一个没有出现在nvm -ls输出中的 Node 版本?

glaucon@polo /media/poloextra/dev/souvenir $ node --version
v7.10.0
glaucon@polo /media/poloextra/dev/souvenir $ nvm ls
         v4.2.2
         v5.5.0
         v7.7.2
         v8.0.0
->       system
default -> stable (-> v8.0.0)
node -> stable (-> v8.0.0) (default)
stable -> 8.0 (-> v8.0.0) (default)
iojs -> N/A (default)

It's a little while since I've used Node and I think perhaps I've misunderstood how nvm does what it does.我已经有一段时间没有使用 Node 了,我想我可能误解了 nvm 的工作方式。 I thought if there was a version of Node installed then it would appear in the nvm ls output我想如果安装了一个 Node 版本,它就会出现在nvm ls输出中


EDIT1 : Responding to comment the output of which -a node is : EDIT1 :回应评论which -a node的输出是:

glaucon@polo /media/poloextra/dev/souvenir $ which -a node
/usr/local/heroku/bin/node
/home/glaucon/.nvm/versions/node/v8.0.0/bin/node
/usr/local/bin/node
/usr/bin/node

(nvm maintainer here) This is intentional; (这里是 nvm 维护者)这是故意的; nvm ls (and nvm current ) outputs that you're using the "system" node; nvm ls (和nvm current )输出您正在使用“系统”节点; which happens to be v7.10.0 .这恰好是v7.10.0 If you run nvm use node , you'll use the latest nvm-installed version, which seems to be v8.0.0 (based on your nvm ls output).如果您运行nvm use node ,您将使用最新的 nvm 安装版本,它似乎是 v8.0.0(基于您的nvm ls输出)。

You can also run nvm alias default node which will auto-use the latest version every time nvm.sh is sourced (ie, when you open your terminal).您还可以运行nvm alias default node ,它会在每次nvm.sh被获取时(即,当您打开终端时)自动使用最新版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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