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

查看:28
本文介绍了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.在操作系统终端运行 -

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

nvm 别名默认 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天全站免登陆