Frederick John
Frederick John

Reputation: 527

How do I set the version of node for VS Code's integrated terminal?

no, this is not a duplicate question. I have read the docs on VS code as well as other posts on stack overflow. The issue still persists...

I can set the node version with nvm, but the terminal in VS code reverts back to 7.6.0, which has problems with yarn!

EDIT: [ Adding Debugging Info from zsh, outside of VS code]

λ  ~  which node                                                     
/Users/Freddy/.nvm/versions/node/v9.6.1/bin/node
λ  ~  node -v                                                                      
v9.6.1
λ  ~  nvm --version                                                                
0.33.8

I use nvm to manage my different versions of node, which works perfectly fine with the exception of VS Code.

Within VS Code terminal, the node version always reverts to v7.6.0:

node -v                                                             
v7.6.0

λ  ~/auth0-profile  nvm use default                                                     
Now using node v9.6.1 (npm v5.6.0)

λ  ~/auth0-profile  node -v     

v7.6.0

λ  ~/auth0-profile  nvm current                                                         
system

λ  ~/auth0-profile  nvm ls                                                              
         v8.9.4
        v8.10.0
         v9.6.1
->       system
default -> 8.10.0 (-> v8.10.0)
system -> 9.6.1 (-> v9.6.1)
node -> stable (-> v9.6.1) (default)
stable -> 9.6 (-> v9.6.1) (default)
iojs -> N/A (default)

Even after I set node to use version v9.6.1 it reverts back to 7.6, which has issues with yarn. And I don't know why nvm current results in "system" when it shows system is 9.6.1 but node -v still shows 7.6.0.

Any ideas?


EDIT2: [as per the docs on vscode, I set the runtime version in launch.json but this didn't work]

I found if i run which node from the terminal in vscode it returns /usr/local/bin/node. To fix this I try setting the runtime Executable in the launch.json file to the executable in the .nvm directory "~/.nvm/versions/node/v8.10.0/bin" but I still had no success.

Upvotes: 9

Views: 20141

Answers (2)

TheScrappyDev
TheScrappyDev

Reputation: 4963

I use nvm (node version manager) for managing my local node versions.

After I upgraded to the LTS (nvm install --lts on MacOS), I aliased the LTS as default (nvm alias default <version>), and then restarted VS Code.

Once VS Code was restarted, the integrated terminal picked up the change from nvm.

Upvotes: 0

pandahao
pandahao

Reputation: 31

Visual Studio Code to use node version specified by NVM

I had the same problem, but the answers like 'nvm use default ' and 'nvm alias...' 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": []

Upvotes: 3

Related Questions