Nodejs 使用 Chrome DevTools 调试 --inspect-brk

参考链接:

https://cnodejs.org/topic/5a9661ff71327bb413bbff5b

https://github.com/nswbmw/node-in-debugging/blob/master/4.2%20Chrome%20DevTools.md

 (补充:推荐结合nodemon使用。可以自动重启,也可以断点调试 $ nodemon --inspect index.js)

index.js

var http = require('http');

var server = http.createServer(function (req, rep) {
    rep.writeHead(200, {"Content-Type": "text/plain"});
    rep.end("Hello World!!");
})

server.listen(3000, function (err) {
     console.log('start');
});

 

运行命令: $ node --inspect-brk index.js

 

打开浏览器:chrome://inspect/#devices

找到下图,并且点击inspect

 

 

 

我们可以自由加入断点,也可以打印出当前的变量。

 

 

posted @ 2018-07-16 21:32  贝尔塔猫  阅读(7614)  评论(0编辑  收藏  举报