7

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

3
  • 1
    Shouldn't Maek be Make? (pro-tip. copy and paste) Commented Feb 22, 2023 at 20:13
  • 1
    Do you have Node.JS installed on your system? Commented Feb 22, 2023 at 20:14
  • @Wyck - Yes, it should me Make. I couldn't copy and paste because it was a popup window. Commented Feb 22, 2023 at 21:56

4 Answers 4

8

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

Sign up to request clarification or add additional context in comments.

2 Comments

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
thanks, do you know why is it working?
4

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.

1 Comment

This worked for me. I also did have complications with node not found when using ZSH and not BASH. I had to change the path in BASH to reflect where NODE could be found. I'm not sure how that happened, it was installed with HOMEBREW!?
2

this is likely because you installed node with nvm, at least thats why i used to get this error.

start code from the terminal after checking that your PATH contains the folder in which node is installed

assuming a nix like env you can check this with

which node

if starting from terminal without having to add your PATH variable works then the issue likely lies in the fact that the PATH is being added to in ~/.bashrc rather than ~/.bash_profile

set the PATH to include your node installation directory in ~/.bash_profile and then reboot. when you next open vscode and try debugging it should pick up the installation automatically.

or there is the runTimeExecutable option you can set in the launch.json for the js project you're working on.

2 Comments

Based on "window pops up asking me to select a debugger: ... Web App (Edge)" I would not assume it's a "nix like env" -- but I could be wrong, there are lots of ways to get a "nix like env" even on Windows. You could request clarification from the asker in a comment, if you wanted to know for sure.
There are edge builds for linux and macos. the steps to fixing on windows are likely quite similar, find where your path is defined, and make sure the node installation dir is in there and effective across the whole session
0

Adding to the launch.json file by adding the field of "runtimeExecutable" with a value of running "which node" in the terminal worked for me.

1 Comment

FYI: @stanley 's answer above says the same, but in more detail...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.