Visual Studio Code to use node version specified by NVM

Aseem Gautam picture Aseem Gautam · Jun 22, 2017 · Viewed 57.2k times · Source

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

Answer

Sm Srikanth picture Sm Srikanth · Jul 31, 2018

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"
    }
]}