Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
441 views
in Technique[技术] by (71.8m points)

node.js - Visual Studio Code to use node version specified by NVM

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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...