节点检查员与快递4 [英] Node-inspector with Express 4

查看:133
本文介绍了节点检查员与快递4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Express 4 App运行节点检查器 - 我正在运行Vagrant框,但能够浏览浏览器中的页面没有任何问题(我的移动机器上的端口可用于主机)。

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).

我使用 npm开始节点--debug bin / www 然后启动节点调试器 bin / www 。我在浏览器中加载检查器,并且在第一行加载了初始断点,但在页面上执行任何操作可能会触发断点导致$ code> EADDRINUSE (也称为端口正在使用中)错误。对于什么可能导致这一点,我有点困惑,但是,我使用的命令非常有可能在Express 3而不是4上运行。另外,也许有一些配置我缺少运行调试器在浏览器,但在流氓框上运行检查器?

I fire up the application either with npm start or node --debug bin/www and then start the 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. 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?

推荐答案

更新 m很确定这是你的问题:

Update: I'm pretty sure this is your problem:


节点--debug bin / www然后启动node-debugger bin / www。 p>

node --debug bin/www and then start the node-debugger bin/www.

不要做那些 BOTH 。这是一个或另一个。他们是做同样事情的两种方式。无论您是否使用节点检查器,我都喜欢以前的方法,因为它更简单,并且与节点本身一起使用。

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.

总结:


  • node-debug bin / www 在调试模式下启动您的应用程序,并在同一进程中启动节点检查器

  • 节点--debug bin / www 以调试模式启动您的应用程序。这应该与单独的终端窗口组合,您可以单独运行 node-inspector 作为单独的进程。我推荐这种方法,但是应该可以使用。

  • node-debug bin/www starts both your app in debug mode AND node-inspector in the same process
  • node --debug bin/www starts your app in debug mode. This should be combined with a separate terminal window where you run node-inspector as a separate process. 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:


  • 在您的流氓主机内的一个ssh会话终端中,直接启动您的应用在节点的前台,--debug ./bin/www

    • v8将尝试绑定到端口5858.你应该看到这个消息调试器监听端口5858,而不是此消息无法打开端口5858上的套接字,等待1000 ms重试之前

    • 如果您看到无法打开套接字在端口5858消息,还有一个进程已经在侦听。运行 sudo netstat -ntlp 以查看它是哪个进程,了解它是什么,为什么它正在运行,然后杀死它以释放端口杀死< pid-you-got-from-netstat>

    • in one ssh session terminal inside your vagrant host, start your app directly in the foreground with 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"
      • If you see the "Failed to open socket on port 5858" message, there's another process already listening. 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>

      这篇关于节点检查员与快递4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆