5

I want to debug my Node.Js code in visual studio code. when I add break point and starts debugging it gives me error "Cannot find runtime 'node' on PATH". I am runnimg VS Code in ubuntu 18.04. Can some help me in fixing this issue? Any help in this regard will be highly appreciated.

1
  • Yes, Node is installed. As, when I run command node -v in bash, it gives v10.7.0
    – Al Fahad
    Commented Aug 14, 2018 at 12:56

3 Answers 3

10

After alot of searching I resolved this issue myself by following these two steps:

  1. I opened the Integrated terminal and type command which node. In my case it responded with /home/user/.nvm/versions/node/v10.7.0/bin/node
  2. Then I added an attribute "runtimeExecutable" in launch.json file and to its value I passed the path received by entering command mentioned in step one. like this "runtimeExecutable": "/home/user/.nvm/versions/node/v10.7.0/bin/node",

Screenshot of launch.json file after adding "runtimeExecutable" in configurations

After following these two steps, I added break point and started debugging. It started debugging.

2

I had a similar issue with zsh and nvm on ubuntu 18.10, I fixed it by adding nvm initialization script in ~/.profile and restart login session like this

export NVM_DIR="$HOME/.nvm" 
 [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm 
 [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
2

I have the same problem, but I have installed 2 VSC versions, one from deb package (that works without the problems) and one from Snap store that have this problem. I'm using nvm for node. Problem is that snap VSC version is running as a root and don't have node in path (even if it works in development console). I fixed this by symbolic link of node executable for root:

sudo ln -s "$NVM_DIR/versions/node/v10.16.0/bin/node" "/usr/local/bin/node"

where v10.16.0 is my current node version.

1
  • Thanks, this worked to fix my problem. Nothing anyone else had put on similar issues worked and I was at a loss as to what was causing it. Commented May 6, 2021 at 15:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .