最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Visual Studio Code: "can't find nod.js binary "node": path does not exist.&q

programmeradmin8浏览0评论

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

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

Share Improve this question edited Feb 22, 2023 at 20:49 D. Dub asked Feb 22, 2023 at 20:10 D. DubD. Dub 711 gold badge1 silver badge4 bronze badges 3
  • 1 Shouldn't Maek be Make? (pro-tip. copy and paste) – Wyck Commented Feb 22, 2023 at 20:13
  • 1 Do you have Node.JS installed on your system? – Josh 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. – D. Dub Commented Feb 22, 2023 at 21:56
Add a comment  | 

4 Answers 4

Reset to default 7

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

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.

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.

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.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论