Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code: "can't find Node.js binary "node": path does not exist."

I'm very new to coding and am starting with JS using Visual Studio Code. I'm following some of their tutorial videos and on the very first one when I hit F5 to run the script, I get the following popup error:

Can't find nod.js binary "node": path does not exist. Maek sure Node.js is installed and in your PATH, or set the "runtimeExecutable" in your launch.json

Then if I click on the Launch.json button it takes me to the code for that, but I'm not sure what to do there. Like I said, very new to coding. I've done some codecademy, but I want to start using an IDE.

EDIT: I uninstalled and reinstalled VS Code and started a new project. I created the folder to save into and title my plain text project as "jsSample.js"

Here's my script:

console.log("---------------");

console.log("Rise & Shine!");

console.log("Ready to learn!");

console.log("---------------");

Then when I hit F5 this window pops up asking me to select a debugger. It lists:

  • Node.js
  • VS Code Extension Development
  • Web App (Chrome)
  • Web App (Edge)

  • Install an extension for JavaScript...

I obviously selected Node.js the first time I tried this, but since reinstalling, I don't know which selection to choose to simply get this to output in the default Debug Console

like image 672
D. Dub Avatar asked Jul 19 '26 16:07

D. Dub


2 Answers

You can fix this error by doing following 2 steps.

for windows :

  1. open cmd prompt , then type code .
  2. Restart VS code

for me it worked

like image 90
Ujwala Nuti Avatar answered Jul 21 '26 05:07

Ujwala Nuti


The easiest way to fix this error is to create and update the launch.json file with the "runtimeExecutable" property.

This solution is for Linux (specifically Ubuntu), let me know how to adapt it to other OS and I will update it.

  1. First you need the location of your node binary. To find this, open a terminal with ctrl + alt + t or open it by some other means and type which node. You will get an output like this:
/home/dave/.nvm/versions/node/v18.16.1/bin/node
  1. Next create a launch.json file in a .vscode folder. The quickest way to do this is just to click on the debug icon on the left hand menu, and then selectcreate a launch.json file, which is just under Run and Debug. It will ask you to select a debugger, select Node.js.

  2. Edit that file when it appears, by adding the "runtimeExecutable" field, with its value set to the path to your node binary from step 1. Remember to add a comma after that last field, which should be "program". Your launch.json file should look something like:

`

  1. Save your file. That should do it, next time you click on the debugger it should run as expected.
like image 41
stanley Avatar answered Jul 21 '26 04:07

stanley