- List available commands from the debugger:
help
$ node debug <entry_file>
- Get the pid of the node process:
$ ps aux | grep "search" - Attach the debugger:
$ node debug -p <pid>
💡 Attaching the debugger or starting the process with the debugger attached automatically breaks on entry
💡 In order to hit any breakpoints you need to start the process with the
debugoption (node debug <entry_file>)
- Set static/code breakpoints: insert
debugger;directly in the code - Set static/code conditional breakpoints: insert
if (<condition>) debugger;directly in the code
💡 The following commands pertain to the debugger when a breakpoint is met or code is paused
- Set a breakpoint on the current line:
sb() - Set a breakpoint on line_number in the current file:
sb(<line_number>) - Set a breakpoint on line_number in file_name:
sb(<file_name>, <line_number>) - Remove a breakpoint:
cb(<file_name>, <line_number>) - List all breakpoints:
breakpoints
💡 The following commands pertain to the debugger when a breakpoint is met or code is paused
- Continue until next breakpoint:
c - Step to the next statement in the current function:
n - Step in to the next statement or into the next function:
s - Step out of the current function on the stack:
o
💡 The following commands pertain to the debugger when a breakpoint is met or code is paused
- List the current source and line_count before and after:
list(<line_count>)(defaults to 5) - Run an expression in the current context:
exec <expr> - Watch an expression:
watch('<expr>')(watched expressions display at every breakpoint or when runningwatchers) - Stop watching an expression:
watch('<expr>') - Display all watched expressions:
watchers
- Terminate the program:
kill - Terminate the program and exit the debugger:
quit - Restart the program:
restart