简体   繁体   English

我无法使用 nvm 在 OSX 下更改 vscode 上的 nodejs 版本

[英]I cannot change the nodejs version on vscode under OSX using nvm

I see in vscode terminal, my nodejs version is v11.5.0, I need to change the version to 12.13.0, and i do nvm use 12.13.0 , it successfully executed, then node -v , it is still 11.5.0, as the sreenshot below.我在vscode终端看到,我的nodejs版本是v11.5.0,我需要把版本改成12.13.0,我做nvm use 12.13.0 ,执行成功,然后node -v ,还是11.5.0,如下图所示。

At the /bin/bash from system, i tried node -v , it 12.13.0.在系统的/bin/bash中,我尝试了node -v ,它是 12.13.0。

Why cannot i change the version?为什么我不能更改版本? anyone help.任何人都可以帮助。 thanks.谢谢。 you can see the nvm ls below in the screenshot.您可以在屏幕截图中看到下面的nvm ls

in vscode terminal在 vscode 终端

~$ node -v
v11.5.0
~$ nvm use 12.13.0
Now using node v12.13.0 (npm v6.10.2)
~$ node -v
v11.5.0
~$ nvm ls
       v10.13.0
       v10.15.0
       v10.15.1
       v10.16.0
       v12.13.0
->       system
default -> 12.13.0 (-> v12.13.0)
system -> 12.13.0 (-> v12.13.0)
node -> stable (-> v12.13.0) (default)
stable -> 12.13 (-> v12.13.0) (default)
iojs -> N/A (default)
lts/* -> lts/erbium (-> v12.13.0)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.16.2 (-> N/A)
lts/dubnium -> v10.17.0 (-> N/A)
lts/erbium -> v12.13.0
~$ 

in iTerm在 iTerm 中

Last login: Fri Oct 25 10:49:41 on ttys000
~$ node -v
v12.13.0
~$

Thanks to @tuan-anh-tran, i try this:感谢@tuan-anh-tran,我试试这个:

in vscode terminal在 vscode 终端

~$ which node
/usr/local/bin/node

in system terminal在系统终端

~$ which node
/Users/lennon/.nvm/versions/node/v12.13.0/bin/node
~$

what's wrong?怎么了? Both the terminals is /bin/bash , why the node is different?两个终端都是/bin/bash ,为什么节点不同? is anywhere i should do some settings?在哪里我应该做一些设置?

screenshot截屏

Thanks to @tuan-anh-tran again for nice helping.再次感谢@tuan-anh-tran 的帮助。

By following your tips, I tried brew info node , and i found that the nodejs@11.5.0 is installed sometime earlier.按照您的提示,我尝试了brew info node ,我发现 nodejs@11.5.0 安装得更早。

So that i execute brew uninstall node , and reopen vscode terminal, the version is 12.13.0, that is correct!所以我执行brew uninstall node ,然后重新打开 vscode 终端,版本是 12.13.0,没错!

The problem solved, but i still do not known why the node s(in vscode terminal and in system terminal) will point to the different program in the same terminal /bin/bash , might anywhere need to do some settings.问题解决了,但我仍然不知道为什么node s(在 vscode 终端和系统终端中)将指向同一终端/bin/bash中的不同程序,可能需要在任何地方进行一些设置。

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

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