Visual Studio Code使用NVM指定的节点版本 [英] Visual Studio Code to use node version specified by NVM

查看:366
本文介绍了Visual Studio Code使用NVM指定的节点版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

VS Code是否可以使用NVM指定的节点版本?

Is it possible for VS Code to use node version specified by NVM?

我在本地安装了6.9.2.即使从OS X终端(不是VS Code终端)切换到另一个版本后,重新启动VS Code,VS Code仍会使用6.9.2显示.

I have 6.9.2 installed locally. Even after switching to another version, from the OS X terminal (not the VS Code terminal), restarting VS Code, VS Code still shows using 6.9.2.

OS X终端

MacBook-Pro-3:~ mac$ node -v
v7.8.0

VS Code终端

MacBook-Pro-3:QB-Invoice-API mac$ node -v
v6.9.2

推荐答案

解决方案是设置别名default.在OS终端中运行-

The solution is to set alias default. In the OS terminal run -

nvm alias default 7.8.0

打开vscode,现在运行node -v会返回7.8.0

Open vscode, now running node -v returns 7.8.0

似乎vscode占用了此值(别名默认值),而不是nvm use X.X.X

It seems vscode takes up this (alias default) value and not the node version that is set by nvm use X.X.X

重新启动VS代码以获取更改.

Restart VS code for it to pick up the changes.

更新(12/04/2018)-此解决方案可能不适用于所有人.请参阅以下答案以了解其他解决方案.

Update (12/04/2018) - This solution might not work for everyone. Please see below answers for other solutions.

这篇关于Visual Studio Code使用NVM指定的节点版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆