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

2

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
    }
  ]
}
Lorenza answered 2/1, 2020 at 13:59 Comment(4)
I think this is what direnv tries to solve: 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.Nomadize
@Nomadize Thank you for commenting. Indeed, that is maybe a very good solution. I need some time to look into that.Lorenza
@Lorenza how did it go? I tried it, and it's nice and all, but still having the same issueAurar
@Aurar Eventually switched to devcontainers and stopped using asdf.Lorenza
E
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.

Electoral answered 20/8, 2020 at 12:58 Comment(0)
P
2

For me worked to set an asdf global version for node

asdf global nodejs 16.13.1
Pardoes answered 24/3, 2022 at 19:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.