I've installed node-inspector and express, and succeeded to start debugging with the url http://{localhost}:8080/debug?port=5858.
But I'm developping a static file server, and want to verify how the code is running when the request comes from http://{localhost}:8080/javascript/abc.js. How can I do that? What is the correct url in this case?
Let's assume your express application is listening on port 3000:
var app = express();
app.use(express.static(path.join(__dirname, 'public')));
express.listen(3000);
and your Node-Inspector is listening on 8080 as you mentioned in your question.
How to step through the code handling a request for a static file:
Open Node Inspector in the first browser tab (http://localhost:8080/debug?port=5858
).
Set a breakpoint in the static file handler. If you are using express.static
, then you need to find this file:
node_modules/express/node_modules/connect/lib/middleware/static.js
Shortcut: press Ctrl+O (Cmd+O on Mac) and type static.js
to the search box.
Open your application in another browser tab (http://localhost:8080/javascript/abc.js
).
The browser should show progress and be waiting for the response from the server. The response is not coming because the server is stopped at a breakpoint.
Switch to the first tab with Node Inspector and do your debugging.