简体   繁体   English

您实际上如何使用node-inspector进行调试?

[英]How do you actually do any debugging with node-inspector?

I read about node-inspector as a suggestion for debugging node code. 我阅读了有关node-inspector作为调试节点代码的建议。

However I have found no clear instructions on how to use it, and the documentation is awful. 但是,我没有找到有关如何使用它的明确说明,并且该文档太糟糕了。

I installed node-inspector and then did 我安装了node-inspector ,然后做了

node-inspector --web-port=5858 &

I get a message saying 我收到一条消息说

Visit http://127.0.0.1:5858/?ws=127.0.0.1:5858&port=5858 to start debugging.

which I do. 我做的。

Now I get a blank console page. 现在,我得到一个空白的控制台页面。

But the docs stop here. 但是文档到此为止。 What do I do next to actually debug my app? 要实际调试应用程序,我该怎么办?

空白节点检查器控制台

Click the 'source' tab to see all the files used by your nodejs project. 单击“源”选项卡以查看您的nodejs项目使用的所有文件。 When the debugger starts it stops code execution at the first line automatically without setting any breakpoint, this lets you set more breakpoints if necessary. 调试器启动后,它将自动在第一行停止代码执行,而无需设置任何断点,这使您可以在必要时设置更多的断点。 After setting breakpoints, click on 'Run' or 'Resume execution' button to proceed. 设置断点后,单击“运行”或“恢复执行”按钮以继续。

For the first usage you can follow next instruction: 首次使用时,您可以按照以下说明进行操作:

  1. Create new project with only index.js 仅使用index.js创建新项目

 var a = 0; setTimeout(function() { debugger; console.log(a++); }, 1000); 

  1. Open your preferred shell in project dir and execute node-debug index 在项目目录中打开您首选的shell并执行node-debug index

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM