丶 Limeー来夢 丶
丶 Limeー来夢 丶

Reputation: 947

Why VSCode keeps using old node.js version on nvm?

I have an issue on node.js debugging on vscode, it no matter what I do persists on a particular node.js version on nvm.

lets say I have the following simple launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "webpack launch",
      "program": "npx",
      "args": [
        "webpack",
        "serve",
        "--config",
        "config/webpack.config.dev.js",
        "--port",
        "3051",
      ],
      "autoAttachChildProcesses": true,
      "stopOnEntry": true
    },

note: this has been working completely fine until I recently changed nvm version mainly I use and on an other computer.

if you run the above "webpack launch" debug, in the debug console, it shows:

/home/user/.nvm/versions/node/v13.10.1/bin/node npx webpack serve --config config/webpack.config.dev.js --port 3051

well, I'm not using v13.10.1 anymore, but v17.9.0. I'm saying this for a countless times, vscode. lets do the steps I'm doing to tell vscode to not to use the old version but the v17.9.0 version:

  1. .bashrc

added nvm use v17.9.0 in the last line

  1. nvm alias default

ran nvm alias default v17.9.0

  1. .nvmrc

added nvm use v17.9.0 in ~/.nvmrc

  1. reload/re-launch vscode

reload vscode and/or quit vscode then restart vscode.

  1. check in the terminal

check if nvm working by checking its version on the newly opened vscode instance terminal.

$ nvm current
v17.9.0

$ node -v
v17.9.0
  1. re-try the debug

the same. wow.

/home/user/.nvm/versions/node/v13.10.1/bin/node npx webpack serve --config config/webpack.config.dev.js --port 3051
Process exited with code 1

What tf is going on with vscode? What am I missing here, may I know? Thanks.

Upvotes: 1

Views: 6306

Answers (2)

tfuelber
tfuelber

Reputation: 85

Have you tried nvm alias default node? Or also, nvm alias default <node version without "V", just the number>? Instead of nvm alias default v17.0.0, nvm alias default 17

Upvotes: 0

Prabhsharan Sandhu
Prabhsharan Sandhu

Reputation: 45

I have checked and found out my vscode is reflecting the same version I am changing from the terminal outside the vscode terminal. SO it's working for me let's try some steps for you to fix this problem:

  1. Restart the vscode (which you have already tried). Also restart the pc and check.
  2. Uninstall the older version of node i.e. v13.10.1 if you are not using it again.
  3. Last option is to uninstall vscode and install the latest version of vscode if possible.

There are lots of this kind of scenerios when vscode terminal don't reflect the changes but it gets fixed by just restarting the terminal again in vscode which is not happening in your case. But I hope these 3 steps will help you to get it fixed.

Upvotes: 0

Related Questions