Using the Visual Studio Code debugger

Open up src/index.js on VSCode. If you hover your mouse to the left of the line numbers, you'll see some small, dimmed, red circles appear; you can click on the circle to insert a breakpoint on that line. This means whenever the script is executing and reaches that line, it will pause there. This allows us to examine the variables available within scope at that point. Go ahead and set the breakpoint at line 5.

You may also use the debugger statement, which has exactly the same effect as setting a breakpoint. The only difference is that the debugger statement would now be part of the code, which is usually not what you want:
const requestHandler = function (req, res) {  debugger; res.writeHead(200, {'Content-Type': ...

Get Building Enterprise JavaScript Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.