Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug node js with Visual Studio Code

I try to debug a Project in node JS with Visual Studio Code but i don't achieve. I have built a simple project with the next commands:

express myExpressApp
cd myExpressApp
npm install
npm start

My file launch.json:

enter image description here

I select the Option “Launch app.js” in Window “Debug”. The application run without problems. I put a breakpoint:

enter image description here

I give in Chrome the address: http://localhost:3000/

Visual Studio Code says: “Pause on breakpoint”, but I don't see anything, I can press Continue and the application continues...

Pause on breakpoint

Edited: I use OS X 10.10 (I tested it and it works perfectly in Ubuntu.)

like image 628
jcabello Avatar asked Sep 21 '15 15:09

jcabello


2 Answers

VSCode 0.8.0 has problems with node versions older than 0.12.0. Upgrade to at least 0.12.0 or wait for the upcoming VSCode 0.9.0.

like image 107
Andre Weinand Avatar answered Sep 25 '22 07:09

Andre Weinand


When debugging with Visual Studio Code, there are many things you can do when you hit a breakpoint.

In order to go to the "debugging" view, you can either click the "bug" icon on the left or hit Ctrl + Shift + D.

You see Paused on breakpoint. in the Call Stack window. That window includes the callstack and you can double-click the different frames to navigate through the corresponding source.

You can also see the Variables window here to see the values of the variables (local/global/closure/etc.).

One of the more used functionality parts of debugging in VS Code is the debug console. In the debugging view, there's a little icon right next to the configuration that you're using that looks like the CLI character. You can either click that or just do a command palette search (Ctrl + Shift + P) for Debug: open Console. This will bring up the debugging console for your ad hoc debugging commands.

The documentation on VS Code debugging is quite robust, too, so I recommend you take a look at this.

like image 35
Thomas Stringer Avatar answered Sep 24 '22 07:09

Thomas Stringer