Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Waiting for debugger to disconnect... - Node.js in VSCode

I'm trying to step through a simple javascript example in Visual Studio Code, but the debugger hangs trying to disconnect.

macOS Sierra version 10.12.6

VSCode version 1.18.1 (up to date)

Node.js v8.9.2 (up to date) installed with Homebrew

Debugging with inspector protocol because Node.js v8.9.2 was detected. node --inspect-brk= /*(port)*/ jsSandbox.js  Debugger listening on ws:// (ip address) Debugger attached. Waiting for the debugger to disconnect... 

This seems like it's been a closed issue with both Code and Node already, which is why I'm so confused. Am I doing something wrong?

Here is the only javascript file I'm trying to debug:

// learning about closure  function increase() {  // — gets called once     var getBig = 0;     return function() {  // — — gets called each time          getBig += 1;      // — — increments each time         console.log(getBig);     }; } var bigOne = increase(); // --  a reference to the instance of the function bigOne(); //1 bigOne();//2  

...and the project's launch.json config:

        {             "type": "node",             "request": "launch",             "name": "Launch Program",             "program": "${workspaceFolder}/jsSandbox.js",             "console": "internalConsole"         } 
like image 614
csforbes Avatar asked Dec 07 '17 18:12

csforbes


2 Answers

click on the button as shown below to open launch.json-

To open Launch.json

Give your correct file name here, where your server is starting. In my case it is app.js

"version": "0.2.0", "configurations": [     {         "type": "node",         "runtimeVersion": "10.21.0",          "request": "launch",         "name": "Launch Program",         "program": "${workspaceFolder}/app.js"     } ] 

runtimeVersion is optional, its required if you want to run it on a specific node version.And that node version should be installed on your system.

like image 50
Nayan Patel Avatar answered Sep 20 '22 01:09

Nayan Patel


I found a syntax error in my code. The problem was that I wasn't catching the exception. Using VS Code, I just ticked "Uncaught Exceptions" and found the faulty code.

like image 29
Mojo Avatar answered Sep 20 '22 01:09

Mojo