Search code examples
node.jsexpressnode-inspector

How to use Node Inspector (node-debug) with Express 4?


I am new to NodeJS and I just discovered node inspector.

The command I usually run in order to start my application is npm start (I use the Express framework) but when I want to debug, I need to run node-debug followed by a specific file.

In the official documentation of node inspector it says that in order to start the debugger I need to type :

$ node-debug app.js

But when I do it simply debugs the app.js file instead of running the server and starting the application.

What is the command I should run in order to debug the whole express application instead of only the app.js file?


Solution

  • When we type npm start the express framework looks at package.json file and executes the file next to the start : tag.

    For express, this directory is ./bin/www so the correct command is node-debug bin/www ran from the parent directory instead of node-debug app.js.