7

Unfortunately Visual Studio Code doesn't find the runtime executable node.

Cannot find node

But the integrated terminal knows about node:

$ which node
/home/user/.asdf/shims/node

How can I introduce node to Visual Studio Code without adding the runtime executable to the launch.json explicitly?

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      [...]
      "runtimeExecutable": "~/.asdf/shims/node" // <- want to avoid this
    }
  ]
}
jsejcksn
  • 27,667
  • 4
  • 38
  • 62
Robin
  • 8,162
  • 7
  • 56
  • 101
  • 1
    I think this is what direnv tries to solve: https://github.com/asdf-community/asdf-direnv Did you figure it out? I'm contemplating switching to asdf from nvm and will encounter this, too, if I do. – jsejcksn Jan 30 '20 at 05:12
  • @jsejcksn Thank you for commenting. Indeed, that is maybe a very good solution. I need some time to look into that. – Robin Jan 30 '20 at 05:58
  • @Robin how did it go? I tried it, and it's nice and all, but still having the same issue – FMGordillo Mar 17 '21 at 02:10
  • 1
    @FMGordillo Eventually switched to devcontainers and stopped using asdf. – Robin Mar 17 '21 at 06:30

2 Answers2

4

It seems VSCode first tries to resolve a Node binary before blindly executing it. In my case I didn't have a global Node version set, which causes that check to fail.

I simply set a global version, VSCode's checks pass, and then it runs the local version happily, without any ASDF-specific launch config.

Marius Marais
  • 956
  • 6
  • 7
2

For me worked to set an asdf global version for node

asdf global nodejs 16.13.1
Jaciel
  • 21
  • 1