How to debug node js app with breakpoints and everything?

jayarjo picture jayarjo · Jul 23, 2012 · Viewed 35k times · Source

I've installed node-inspector just to find out that it doesn't support breakpoints :| What's the point in it at all, bearing in mind that on big part node code is asynchronous and you simply cannot follow it step by step?..

I'm definitely missing a point here...

Anyway to debug node code with breakpoints and everything?

Answer

rdrey picture rdrey · Jul 23, 2012

yupp, I've successfully used node-inspector. If you want permanent breakpoints, simply insert debugger; in your code. See http://nodejs.org/api/debugger.html.

Making node wait until a debugger is attached, using node --inspect-brk script.js (previously node --debug-brk script.js), can also be very helpful.