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

参考链接:

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

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

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

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

 

猜你喜欢

转载自www.cnblogs.com/CyLee/p/9320569.html