Debugging server side with node.js

mysamza picture mysamza · Oct 15, 2015 · Viewed 8.4k times · Source

I have a burning question in my head regarding debugging, you see when I am writing Javascript client side I can go to Chrome's console and track my variables and objects etc to see what is happening with my code better.. I am just not able to get my head around about how can we do the same on the server side (node js)? Let's say my front end submitted a form to my express server, how do I go about checking if for instance the req object even received it or not? where do I go about checking variables and objects (debugging) server side code? I definitely can't do it on console of browser as the code exists and executes on the server side so I can't access server side objects etc through browser's console.

Answer

Ben picture Ben · Oct 15, 2015

You can still do console.log(). It'll print to the screen where you run the server. However, it's not as good as walking through the code with debugger which you can set breakpoints and do lots of other things debuggers can do. I've used both webstorm's debugger and node-inspector.

You might want to look into node-inspector. The debugger is like Chrome's Dev-Tool, which you might be familiar with. The link below provides everything from installation to tutorials.

https://github.com/node-inspector/node-inspector