if we want to run node in a debug mode we can simply run
node debug <nodeScriptFileName>
And if we put debugger command inside the script then it will stop in those location and allow us to choose what to do:
- for continue.
- for step in
- for step out
- for restarting
- output the backtrace for the current execution
- for evaluation and executing code:
we can press p anytime to pause the script.
If we the script already started to run then we need to get its process id and the debug it by running the following:
node debug -p <processId>
Anther option is to use node-inspector.