Search code examples
node.jsnode-inspectornode-debugger

What is the difference between "node-debug index.js" and "run node-inspector, then node --debug index.js"


I try to use node-inspector to debug my node apps. At first, I use

node-debug index.js

but the inspector wont stop at debugger statement, also I am unable to set breakpoints.

But if I run

 node-inspector

then run node with debug flags

 node --debug index.js

the inspector works like a charm.

So what is the difference between these two? I try to read https://github.com/node-inspector/node-inspector/blob/master/bin/node-debug.js but frankly no understand :O

Thank you very much!

I use mac osx 10.10.2


Solution

  • Basically, node-debug loads the node-inspector but also sets some default configurations.
    See this statement in the docs While running node-debug is a convenient way to start your debugging session, there may come time when you need to tweak the default setup.

    The full list of what it preloads is sort of hard to figure out (I don't know of any real listing of differences). But if you really go through the docs you can kind of get an idea.
    node-debug

    >Debug
    The node-debug command will load Node Inspector in your default browser.
    
    
    >The debugged process must be started with --debug-brk, this way the script is paused on the first line.
    Note: node-debug adds this option for you by default.
    

    Also, check out the config options for each one (node-debug and node-inspector)