简体   繁体   English

Express 4的节点检查器

[英]Node-inspector with Express 4

I am trying to run node-inspector with an Express 4 App -- I am running this in a Vagrant box but am able to view the pages in the browser without any problems (I have the ports on the vagrant machine available to the host machine). 我正在尝试使用Express 4应用程序运行node-inspector - 我在Vagrant框中运行它但是能够在浏览器中查看页面而没有任何问题(我在主机上可以使用vagrant机器上的端口)。

I fire up the application either with npm start or node --debug bin/www and then start the node-debugger bin/www . 我使用npm startnode --debug bin/www npm start应用程序,然后启动node-debugger bin/www I load the inspector in the browser and it hits the initial breakpoint on the first line but performing any action on the page to debug that would trigger a breakpoint causes an EADDRINUSE (aka the port is in use) error. 我在浏览器中加载了检查器并且它在第一行上遇到了初始断点,但是在页面上执行任何操作以调试会触发断点导致EADDRINUSE (也就是端口正在使用中)错误。 I'm a little baffled as to what could be causing this, however, it's very possible I'm using commands that would work on Express 3 instead of 4. Additionally, maybe there is some configuration I am missing to run the debugger on the browser of the host-machine but running inspector on the vagrant box? 关于可能导致这种情况的原因,我有点困惑,但是,我很可能使用可以在Express 3而不是4上运行的命令。另外,也许有一些配置我缺少在运行调试器上主机的浏览器,但在流浪盒上运行检查员?

Update : I'm pretty sure this is your problem: 更新 :我很确定这是你的问题:

node --debug bin/www and then start the node-debugger bin/www. node --debug bin / www然后启动node-debugger bin / www。

Don't do BOTH of those. 不要做两个 It's one or the other. 这是一个或另一个。 They are 2 ways of doing the same thing. 他们是做同样事情的两种方式。 I prefer the former way as it's simpler and works with node itself whether or not you are using node-inspector. 我更喜欢前一种方式,因为它更简单,无论您是否使用节点检查器,它都可以与节点本身一起使用。

To summarize: 总结一下:

  • node-debug bin/www starts both your app in debug mode AND node-inspector in the same process node-debug bin/www在同一进程中启动调试模式和节点检查器中的应用程序
  • node --debug bin/www starts your app in debug mode. node --debug bin/www以调试模式启动您的应用程序。 This should be combined with a separate terminal window where you run node-inspector as a separate process. 这应该与单独的终端窗口结合使用,您可以将node-inspector作为单独的进程运行。 I recommend this approach, but either should work. 我推荐这种方法,但要么应该工作。

Here's my suggestion to start troubleshooting this. 这是我的建议,开始对此进行故障排除。 Try to use the simplest form of the commands to get everything running: 尝试使用最简单的命令形式来运行一切:

  • in one ssh session terminal inside your vagrant host, start your app directly in the foreground with node --debug ./bin/www 在您的vagrant主机内的一个ssh会话终端中,使用node --debug ./bin/www直接在前台启动您的应用程序
    • v8 will try to bind to port 5858. You should see this message "debugger listening on port 5858" and NOT this message "Failed to open socket on port 5858, waiting 1000 ms before retrying" v8将尝试绑定到端口5858.您应该看到此消息“调试器侦听端口5858”而不是此消息“无法在端口5858上打开套接字,在重试前等待1000毫秒”
    • If you see the "Failed to open socket on port 5858" message, there's another process already listening. 如果您看到“无法在端口5858上打开套接字”消息,则还有另一个进程已在侦听。 run sudo netstat -ntlp to see which process it is, comprehend what it is and why it is running, and then kill it to free up the port kill <pid-you-got-from-netstat> 运行sudo netstat -ntlp来查看它是什么进程,理解它是什么以及它为什么运行,然后杀死它以释放端口kill <pid-you-got-from-netstat>
  • In a separate ssh session terminal inside your vagrant host, start the node-inspector web server node-inspector in the foreground. 在vagrant主机内的单独ssh会话终端中,在前台启动node-inspector Web服务器node-inspector Make sure you see the normal output and no errors. 确保您看到正常输出并且没有错误。
  • Now connect to the right URL which is probably something like http://localhost:8080/debug?port=5858 (unless your vagrant IP/port are different) 现在连接到正确的URL,这可能类似于http://localhost:8080/debug?port=5858 (除非您的流浪者IP /端口不同)
  • if you get there and resolve any unexpected errors you see along the way, things really should work, but if not post some exact details about this EADDRINUSE error you see. 如果你到达那里并解决你在路上看到的任何意外错误,事情确实应该有效,但如果没有发布关于这个EADDRINUSE错误的一些确切细节,你会看到。 Is that an exception within your app itself? 这是你的应用程序本身的例外吗? If so, is there a stale instance of your express app already running somewhere else in your vagrant host and thus bound on your application's web server port? 如果是这样,您的快速应用程序的陈旧实例是否已经在您的流浪主机中的其他位置运行,从而绑定在您的应用程序的Web服务器端口上?

同样的过程适用于主管。

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

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