Visual Studio Code to use node version specified by NVM

vscode node version
vscode integrated terminal nvm
node version manager visual studio code
how to check node version in visual studio code
nvm-windows
set node version visual studio code
node version vs code
nvm vscode terminal

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

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 terminal

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

VS Code Terminal

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

In VS Code, go to your launch.json file and add the runtimeVersion attribute inside configurations, as shown below. (In this example, we are assuming 4.8.7 is already installed using nvm)

{
"version": "<some-version>",
"configurations": [
    {
        "type": "node",
        "runtimeVersion": "4.8.7", // If i need to run node 4.8.7
        "request": "launch",
        "name": "Launch",
        "program": "${workspaceFolder}/sample.js"
    }
]}

Getting Visual Studio Code and NVM Working Together, shell commands will use that specified version. Using .nvmrc. Add a .nvmrc file to the project, containing in plain text the version of node you wish  Integrating with Visual Studio Code. However, there’s an issue with Microsoft’s fantastic Code editor. Code has amazing Node.js support, allowing the running and debugging of your node process, so has become my preferred editor. But I couldn’t get it to use the correctly version of node by using nvm and .nvmrc files.

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

nvm alias default 7.8.0

Open vscode, now running node -v returns 7.8.0

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

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

vsc-nvm, Launch VS Code Quick Open ( Ctrl+P ), paste the following command, and press enter. Automatically running nvm use on each terminal opened when an .​nvmrc file To be able to pick different node versions, you must have nvm installed launch.json for running version picker with specified nvm dir  Hi, thank you for great app. So, I hope VS Code sets specified environment variables when it starts. I use a NodeJS Version Manager such as nvm, then a path to NodeJS is not added to PATH until nvm

add runtimeExecutable to your .vscode/launch.json like this

{
  "type": "node",
  "request": "launch",
  "name": "App",
  "program": "${workspaceRoot}/index.js",
  "runtimeExecutable": "${env:HOME}/.nvm/versions/node/v6.9.2/bin/node"
}

Debug Node.js Apps using Visual Studio Code, 1" to your launch configuration. Note: If VS Code detects that "nvs" is installed, it does not fall back to "nvm" if a specific Node.js  it would be nice if one could nvm (version) -run somescript or similar for executing npm scripts with a specific version of node with everything after the -run passed to node as parameters nvm 0.11.10 -run --harmony my-new-tool.js as an example..

VS Code with NVM · Issue #1895 · microsoft/vscode · GitHub, So, I hope VS Code sets specified environment variables when it starts. I use a NodeJS Version Manager such as nvm, then a path to So when I run my Node.​js project in debug mode in Visual Studio Code (Code was  Simplify your node versioning workflow with nvm and this extension. Features. This extension simplifies nvm workflow by: Automatically running nvm use on each terminal opened when an .nvmrc file exists in your workspace; Providing a command input hook to choose a version of node to run tasks against; Requirements

I had the same problem, but the above answers didn't help.

Apparently the default shellArgs for osx are set to bash while I'm using zsh. I solved the problem by setting the shellArgs in my user settings to an empty array:

"terminal.integrated.shellArgs.osx": []

VSCode unable to find Node under NVM · Issue #68305 · microsoft , VSCode Version: 1.30.2 OS Version: Linux x64 4.19.16-1-MANJARO 2.0.16 Chrome: 61.0.3163.100 Node.js: 8.9.3 V8: 6.1.534.41 Steps to https://github.​com/Microsoft/vscode/blob/master/src/vs/code/node/shellEnv.ts#L24 what $​SHELL is set to and where exactly nvm's init script is being run? Code Visual Studio pour utiliser un nœud version spécifiée par NVM est-il possible pour le code VS d'utiliser la version de noeud spécifiée par NVM? j'ai 6.9.2 installé localement.

Use the correct version of Node when starting VS Code terminal , Use the correct version of Node when starting VS Code terminal session using There are times I am working in a project that requires a specific version of Node. Sure I could have an .nvmrc file, but then I would have to remember to issue nvm use . Example 4 - Debugging PHP in Visual Studio Code. Node.js debugging in VS Code. The Visual Studio Code editor has built-in debugging support for the Node.js runtime and can debug JavaScript, TypeScript, and many other languages that are transpiled into JavaScript. Setting up a project for Node.js debugging is usually straightforward with VS Code providing appropriate launch configuration defaults and snippets.

NVM and Visual Studio Code, How to use the Node Version manager (NVM) with the Visual Studio Code (VS Code) editor. Visual Studio Code (VS Code) is a great lightweight editor that is You could also specify for it to install into your ~/.bash_profile . Node.js is the runtime and npm is the Package Manager for Node.js modules. Visual Studio Code has support for the JavaScript and TypeScript languages out-of-the-box as well as Node.js debugging. However, to run a Node.js application, you will need to install the Node.js runtime on your machine.

Use NVM in your VSCode 1.31 tasks : javascript, I decided to make a quick little extension allowing me to switch and choose between node versions in my VSCode tasks since before I'd have to hard-code the  So, clearly, whatever's causing the query to return 6.14.3 from windows command line `bash -c "node -v" is also responsible for why my Visual Studio Code is launching with that version. However, I'm relatively new to linux/node/nvm/npm, so I'm not quite understanding why there's a disconnect between what I'm seeing from the bash terminal and

Comments
  • Related (and possible duplication): stackoverflow.com/questions/24585261/…
  • This should be the selected answer.
  • I was going to ask how Code knows where to find this version, but apparently, this option was added specifically for nvm. code.visualstudio.com/docs/nodejs/…
  • This worked great for me, no need to make a launch.json this way. I don't know why you got a down vote on your answer. +1
  • This worked for me as well, but there should be an easily way to specify the path to node globally for VSCode.
  • This did not work. After aliasing, I have to use nvm use default everytime I use a new terminal
  • Didn't work for me either. Nor did using nvm use default.
  • I had to remove my brew-installed version of node before this worked.
  • Worked like a charm :). Thanks for sharing
  • Glad it helped! ;)
  • This should be the accepted answer. I was previously setting the runtimeVersion in launch.json but that only sets the node version for a specific task. This works throughout the integrated terminal instance. Thanks! NB. I had to set the PATH var in .zshrc since I'm using zsh for it to work
  • After reading the alternative link provided - which suggested the problem was with nvm and the way it handles subshells - i updated nvm to v0.34.0 and it works without the reset path workaround.
  • simple and awesome +1