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" }
click on the button as shown below 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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With