Here are the main steps and the ways to leverage your new ‘hammer’.
There is a very nice project that let you use the Chrome (read as Blink!) DevTools with a node module in order to have the powerful debugging options web developers got inside Chrome. Think on the ability to set a breakpoint and later going into functions and examine variables, objects on the fly. All you need to install is NodeJS (dah!) and since these days, NodeJS is coming with npm (=managing NodeJS modules) it’s one line of typing after you have node in order to install this module: node-inspector
$ npm install -g node-inspector
Now, you should start your node application with the following command in order to enter the debugging mode:
$ node --debug yourApp.js
or, to pause your script on the first line:
$ node --debug-brk yourApp.js
After you enable the debugging you should follow these steps:
- Start the inspector. I usually put it in the terminal (on the side to see the log massages)
$ node-inspector &
- Open your Chrome and type this:
You wanna make sure these ports are not blocked before step #1.
- Select a script and set some breakpoints (far left line numbers).
- Done! You can now debug your NodeJS application like a pro.
(!) Click on the image to see it in full size