How to PROPERLY debug node.js with node inspector?

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

node --debug-brk myfile.js

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.js you 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-brk of course.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)