'How to use NodeJS debugging in Visual Studio Code with asdf? (cannot find runtime 'node')

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


Solution 1:[1]

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.

Solution 2:[2]

For me worked to set an asdf global version for node

asdf global nodejs 16.13.1

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Marius Marais
Solution 2 Jaciel