简体   繁体   中英

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:

在此输入图像描述

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

在此输入图像描述

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...

暂停断点

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

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM