Debugging
Definition#
Debugging involves examining and testing software to understand its behavior, identify any anomalies or errors.
Node.js#
VSCode#
Getting started#
You can attach VSCode to a Node.js process in only two steps. See docs.
- Launch the process in debug mode:
- Run and attach:
node --inspect index.js
- Wait for the debugger to attach before running:
node --inspect-brk index.js
- Attach VSCode to the process:
Press CTRL+Shift+P
to open a Quick Pick menu, then select Debug: Attach to Node Process
.
Choose the process you want to debug. Then, the Run and Debug
window will appears:
Restart frame#
The Node debugger supports restarting execution at a stack frame. See docs.
Tutorial - GIF
Conditional breakpoint#
Conditional breakpoints are breakpoints that only pause when an expression returns a truthy value. See docs.
Tutorial - GIF
Logpoints#
Log a message or value when code hits a certain location. See docs.
Tutorial - GIF
The arguments object#
arguments is an array-like object accessible inside functions that contains the values of the arguments passed to that function.
Demo - Custom debug function