In order to debug a node.js server, you only need the node-inspector debugger package.
To install it, run the following command:
npm install node-inspector
Suppose that after installation you have the following directory structure:
C:\Program Files\nodejs +---node_modules | +---node-inspector | | +---bin | | | +---inspector.js
In command prompt, go to the root folder of node.js, and type the following command:
C:\Program Files\nodejs>node node_modules\node-inspector\bin\inspector.js
Now, open another command prompt and go to the root folder of your node.js project, and type the following command:
C:\Program Files\nodejs\Workspace\MyProject\src>node --debug index.js
Everything is set and done now. To start debugging, open in one browser tab the following URL http://localhost:8080/debug?port=5858 and in another tab go to your project’s URL.
In the first tab you can navigate through your project’s source files, set breakpoints, run step by step, view the call stack etc. just like you would normally debug a client js file.