3

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.

Frederick John
  • 437
  • 1
  • 6
  • 14
  • Possible duplicate of [Visual Studio Code to use node version specified by NVM](https://stackoverflow.com/questions/44700432/visual-studio-code-to-use-node-version-specified-by-nvm) – daniel_sweetser Mar 29 '18 at 05:03

2 Answers2

1

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": []

pandahao
  • 11
  • 1
0

I cannot comment yet so I'm going to try to help you out from here. I was struggling the same as you and found a solution. I posted an answer here, maybe it can help you out with the resources mentioned in it. I don't use zsh but bash, but it wouldn't be that hard to adapt it to your "profile".

Charlyboy
  • 519
  • 4
  • 6