3

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.

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

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.

| improve this answer | |
1

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"
| improve this answer | |
0

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.