当以“node –debug-brk”启动时,节点在第一行不会中断,
以下文件作为节点启动–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/");
在第一行,程序预计会中断,直到使用node-inspector(在另一个terminal上运行)给出的continue命令的最后一行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机器上运行的节点版本v0.12.0如何使它在第一行中断开(即var http = require('http');)。
更新1:
重新启动机器后
-
节点–debug-brk hello-http.js等待debugging器连接显示
$ node –debug-brk hello-http.js侦听端口5858的debugging器
-
节点检查员盯着另一个terminal
-
一旦chrome浏览器连接到http://127.0.0.1:8080/debug?port=5858 节点检查器, 节点程序将继续执行(打印服务器运行在http://127.0.0.1:8000 )而不用等待debugging器发送命令。
$ node –debug-brk hello-http.js在端口5858上侦听的debugging器在http://127.0.0.1:8000/上运行的服务器
这是预期的。 如果是,如何让node-inspector发送断点命令来设置第一行的断点。
只是看起来像node-inspector
器中的错误。
在Node v0.10版本(0.12,1.x)上运行时,这是Node Inspector的已知问题,请参阅https://github.com/node-inspector/node-inspector/issues/534 。