Node Inspector 调试 Node.js 程序

来源:互联网 发布:mac有迅雷吗 编辑:程序博客网 时间:2024/06/03 19:30

Node Inspector 是一款提供界面化调试 nodejs 程序的调试器,使用它可以在浏览器中像调试前端页面一样调试 nodejs 程序。

环境

[dongshaoshuai~/js] ]$node -vv5.3.0[dongshaoshuai~/js] ]$node-inspector -vNode Inspector v0.12.5

安装

npm install -g node-inspecto

测试

test.js

var http = require("http");var a = 0;http.createServer(function(req, res) {    a ++;    console.log(a)    res.end("Hello there");}).listen(8090);

调试 test.js

[dongshaoshuai~/js] ]$node-debug --web-host 192.168.x.xx --web-port 10107 --debug-port 8091 test.js Node Inspector is now available from http://192.168.x.xx:10107/?ws=192.168.x.xx:10107&port=8091Debugging `test.js`Debugger listening on port 8091No browser matching [chrome,chromium,opera] found in the system! If this is not true, submit a bug report on https://github.com/benderjs/browser-launcher2Please open the URL manually in Chrome/Chromium/Opera or similar browser

浏览器打开链接 http://192.168.x.xx:10107/?ws=192.168.x.xx:10107&port=8091
这里写图片描述

加断点,监控变量,打印

访问 http://192.168.x.x:8090/
这里写图片描述

效果:
这里写图片描述

调试:

  • 浏览源文件
  • 设置断点
  • 监控变量
  • 编辑对象
  • 监控 CPU 和 堆栈使用情况
  • 网络请求检查
  • 打印

More Usage

0 0