Node.js Tutorial – Debugger

The tutorial provides the details on the node.js debugger module. The node,js debugger module provides the debugging utilies using in-built debugging client and V8 inspector ( #debugger_v8_inspector_integration_for_node_js ) .

Node.js debugger syntax

The usage of debugging in the node.js can be done by starting the node.js with the inspect argument , provided with the script path for which debugging is to be enabled.


node debug [script.js | -e “script” | <host>:<port>]  

Example : node debug crypto-cipher.js

Node.js Debugger – Points to consider

  • The inclusion of the statement debugger in the script code enables the breakpoint at that line code.
  • The REPL Commands allows the code to be evaluated remotely.
  • The next command enables debugger to step to the next line for debugging
  • Help Commands provides the list of available commands for Debugger
  • Pressing ENTER only without comamds , executes the previous debugger command
  • Node.js debugger allows to watch/ display the values for expressions and variables. The command watch(‘expression_to_watch’) to be typed. To remove the watcher , type the command unwatch(‘expression_to_watch’)
  • The command cont, c allows the continue execution of debugging the code
  • The command step, s allows the step-into the debugging
  • The command out, 0 allows the step-out of the debugging
  • The command pause stops the debugging
  • The command run allows to run the script
  • The command restart allows to restart the script
  • The command kill allows to kill the script