The following file is started as node --debug-brk hello-http.js
hello-http.js
// Load the http module to create an http server.
var http = require('http');
// Configure our HTTP server to respond with Hello World to all requests.
var server = http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.end("Hello World\n");
});
// Listen on port 8000, IP defaults to 127.0.0.1
server.listen(8000);
// Put a friendly message on the terminal
console.log("Server running at http://127.0.0.1:8000/");
At the first line the program is expected to break and until the continue command is given using node-inspector(running on another terminal) the last line console.log("Server running at http://127.0.0.1:8000/"); is not supposed to be printed. But as soon as the node starts it does not break and prints the log.
$ node --debug-brk hello-http.js
Debugger listening on port 5858
Server running at http://127.0.0.1:8000/
Using node version v0.12.0 running on a ubuntu-12.04 LTS machine How to make it break on the first line(i.e var http = require('http');).
UPDATE 1:
After rebooting the machine
The node --debug-brk hello-http.js waits for the debugger to be connected as displayed
$ node --debug-brk hello-http.js Debugger listening on port 5858
node-inspector is stared on another terminal
As soon the chrome browser connects to node-inspector at http://127.0.0.1:8080/debug?port=5858 the node programs continues execution(printing Server running at http://127.0.0.1:8000) with out waiting for the debugger to send commands.
$ node --debug-brk hello-http.js Debugger listening on port 5858 Server running at http://127.0.0.1:8000/
Is this expected. If yes, how to make node-inspector send breakpoint command to set the breakpoint at the first line.