简体   繁体   English

无法让节点检查员工作

[英]Cannot get node-inspector working

I have a basic express app that I am trying to debug but I cannot get node inspector working correctly on OSX 我有一个基本的快速应用程序,我试图调试,但我不能让节点检查器在OSX上正常工作

In one terminal window I run: 在一个终端窗口中我运行:

node --debug-brk server.js

In another terminal window I run: 在另一个终端窗口中我运行:

node-inspector

Node Inspector opens here: Node Inspector在此处打开:

http://localhost:8080/debug?port=5858

In another browser tab I try to open my site here 在另一个浏览器选项卡中,我尝试在此处打开我的网站

http://localhost:8080/

I get printed to screen 我被打印到屏幕上

Cannot GET /

If I open instead 如果我打开了

http://localhost:3000

I get my app because I set this in server.js 我得到了我的应用程序,因为我在server.js中设置了它

app.set('port', process.env.PORT || 3000);

But now none of the breakpoints work in the debugger 但是现在没有一个断点在调试器中起作用

I am sure I am doing something stupid here but I have read the docs and tutorials over and over and I cannot get this to work. 我确信我在这里做了一些愚蠢的事情但我已经一遍又一遍地阅读了文档和教程,我无法让它发挥作用。

The other things I have tried is in one terminal window running: 我尝试的其他事情是在一个终端窗口运行:

node-debug server.js

I get the same thing as above. 我得到与上面相同的东西。 Debug inspector opens and is stopped at first line and my site at 调试检查器打开,并在第一行和我的站点停止

http://localhost:8080

still says 还是说

Cannot GET /

I also tried 我也试过了

node-debug --no-debug-brk server.js

An I get the same result except node inspector in not stopped at first line 除了节点检查器在第一行没有停止之外,我得到相同的结果

Debug inspector opens and is stopped at first line... 调试检查器打开并在第一行停止...

When node-inspector starts debugging an application, by default, it stops at the first line, during the app starting process. node-inspector开始调试应用程序时,默认情况下,它会在应用程序启动过程中停在第一行。 If you try to access your app at http://localhost:3000 with the debugger stopped at the first line, you'll never get to your breakpoints. 如果您尝试在http://localhost:3000上访问您的应用程序,并且调试器在第一行停止,您将永远不会到达您的断点。

Before trying anything, you must resume script execution or start node-inspector with the --no-debug-brk option, to prevent stopping at the first line. 在尝试任何操作之前,必须使用--no-debug-brk选项恢复脚本执行或启动node-inspector ,以防止在第一行停止。

To make sure node-inspector is not stopping at any line at all, what you should do: 为了确保node-inspector器根本不停在任何一行,您应该做什么:

  • put a breakpoint at the line where you have your app.listen call, or; 在你有app.listen电话的app.listen行放一个断点,或者;
  • a more extreme solution: put a breakpoint at every line of your main file. 极端的解决方案:在主文件的每一行放置一个断点。

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

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