当以 "node --debug-brk" 启动时,节点不会在第一行中断

Node does not break at first line when started as "node --debug-brk"

以下文件启动为node --debug-brk hello-http.js

你好-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/");

在第一行程序预计会中断,直到使用节点检查器(运行 在另一个终端上给出继续命令)最后一行 console.log("Server running at http://127.0.0.1:8000/" );不应该打印。但是一旦节点启动,它就不会中断并打印日志。

$ node --debug-brk hello-http.js 
Debugger listening on port 5858
Server running at http://127.0.0.1:8000/

在 ubuntu-12.04 LTS 机器上使用 node 版本 v0.12.0 运行 如何让它在第一行中断(即 var http = require('http');)。

更新 1:

重启机器后

  1. node --debug-brk hello-http.js等待调试器连接显示

    $ 节点 --debug-brk 你好-http.js 侦听端口 5858

  2. 的调试器
  3. node-inspector 在另一个终端上被盯着

  4. 一旦 chrome 浏览器连接到 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) 而无需等待调试器发送命令。

    $ 节点 --debug-brk 你好-http.js 侦听端口 5858 的调试器 服务器 运行 位于 http://127.0.0.1:8000/

这是预期的。如果是,如何让node-inspector发送断点命令在第一行设置断点。

看起来像是 node-inspector 中的错误。

https://github.com/node-inspector/node-inspector/issues/534

当 运行 在 post-v0.10 版本的 Node(0.12,1.x)上时,这是 Node Inspector 的已知问题,请参阅 https://github.com/node-inspector/node-inspector/issues/534。 =11=]