node.js - how can I debug a node app that is started via the command line (cli) like forever or supervisor? -


i'm familiar debugging own node apps (usually node-inspector). today i'd debug else's program. i'm trying track down issue supervisor. naturally add --debug (or debug-brk) command call, passes code supervising.

i've tried adding debugger lines js file supervisor didn't work (probably because no debugger attached @ time). there's bit of race here -- need start debugger , attach supervisor process after starts before processes arguments command line.

what want here stop supervisor , debug before processes command line arguments. how can this?

i had same problem while developing hexo blog. documentation isn't complete yet find myself needing reverse engineer @ times.

the basic idea in node.js cli apps normal node apps exposing os command line interface. on unix systems using line:

#!/usr/bin/env node 

to allow environment execute script.

many cli based node apps try insist install them globally -g option.

npm install -g node-inspector 

i prefer have control of development environment can get, prefer break conventions , check node_modules in source control along installing can locally dropping -g.

npm install node-inspector 

now don't have in order make work, i'm describing setup because relates question. when run node-inspector can't use:

node-inspector 

instead must explicitly invoke within project. executing symlink in node_modules/.bin folder:

node_modules/.bin/node-inspector 

now i'm running node-inspector you.

next need start cli process in debug , optionally pass params it:

node --debug-brk node_modules/.bin/hexo generate 

note explicitly calling symlink here , not simply:

node --debug-brk hexo generate 

if tried line above error: "error: cannot find module".

i hope helps.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -