NodeJS - Debugging


If we prefer not to use console.log, or we think that our problem can be better 
analyzed using breakpoints, we can use the node's built-in debugger.

We will need to use a Blink-based browser such as Chrome to debug.  

node-inspector provides the node-debug command which is a drop-in replacement 
for node.  We can run it:

node-debug fileName.js

or we can use:

node debug fileName.js

This will launch the specified script in Node with debugging enabled and open 
the browser UI (in your default browser).  If Chrome is not our default browser, 
we will have to copy and paste this URL into the Chrome browser's address bar 
and hit the Enter key.  At this point we should see Chrome’s debugging UI. We 
can press F8 to continue script execution until your debugger statement is 
reached. From this point we can debug as usual. In this environment, we only 
have access to inspect and debug the test module, not the AUT.  This UI is 
provided by node-inspector.  The Chrome's developer tool is not actually open.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License