I have an app built in node.js and I use the node inspector in order to debug.
But it’s quite hard because of this:
- My breakpoints are never saved after I restart the server
- I cannot put a breakpoint on a file that has not loaded yet; so I have to step into from the first script to the one I want; REALLY PAINFULL!
How do you really debug node.js with node inspector?
The videos on how to use node.js are quite misleading as everything is into a module…
http://www.youtube.com/watch?v=AOnK3NVnxL8
or this one the scripts appear are already loaded in the first script
http://www.youtube.com/watch?v=HJOH0-g8f6E&feature=mfu_in_order&list=UL
Edit:
Nobody can answer this question? :s
In javascript you can set breakpoints using the
debugger;statement. However, they will only pause node if a debugger is actually attached.So launch your node script using
then launch node-inspector and press the play button to continue to the next breakpoint and it will hit your
debugger;breakpoint (at least that works for me ATM)(as noted in the comments: in recent versions of node you no longer have to separately install node-inspector. If you launch node using
node --debug-brk --inspect myfile.jsyou get a url that launches the debugger in your browser).you still need one extra click after restarting, but at least your breakpoints are saved.
if your breakpoint is not hit automatically, but only after some user action you don’t need the
--debug-brkof course.