【问题标题】:How to use node-inspector with sails.js?如何在sails.js 中使用节点检查器?
【发布时间】:2014-02-17 07:52:27
【问题描述】:

我想调试我的sails.js 应用程序,但我不知道如何在这种情况下启动node-inspector

通常它会去:

$ node --debug myapp.js

如果我正常运行我的sails应用程序:

$ sails lift --prod

然后启动node-inspector

$ node-inspector --debug-port 1337
Node Inspector v0.7.0-2
   info  - socket.io started
Visit http://127.0.0.1:8080/debug?port=1337 to start debugging.

我在检查器 GUI 中收到此错误:

Error: read ECONNRESET. Check there is no other debugger client attached to port 1337.

【问题讨论】:

标签: javascript node.js debugging sails.js


【解决方案1】:

从 Sails 0.9.8 开始,您可以使用 sailsd 在调试模式下调用sails,例如sailsd lift.

-- 编辑--

看起来这实际上并没有进入 0.9.8,我的错。现在要创建自己的调试命令,请将以下内容保存到 /usr/local/bin 中,为 sailsd(或任何你喜欢的):

#!/bin/sh
node --debug `which sails` $@

-- 编辑2--

在 Sails v0.10.x 中,您可以使用 sails debug 而不是 sails lift 以调试模式启动 Sails!

【讨论】:

【解决方案2】:

如果我错了,请纠正我,但是如果帆升降机在 1337 端口上,你不能使用调试端口 1337。

尝试指定不同的端口。

node --debug app.js
#this will lift sails on port 1337 and the default debug port i think its 5858
#start node-inspector, once it starts hit enter to put it into background
node-inspector &;
#visit http://127.0.0.1:8080/debug?port=5858

edit 刚刚确认此方法有效,而不是使用 sails lift 您正在使用 node 在调试模式下启动 app.js。默认情况下,节点检查器 Web 在端口 8080 上运行,调试器链接在端口 5858 上。

【讨论】:

  • 如果sails 中有一个可用的标志来启用调试模式,那就太好了。我要四处看看。
猜你喜欢
  • 2013-12-17
  • 2016-07-31
  • 1970-01-01
  • 2023-04-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-02-11
  • 2017-02-03
相关资源
最近更新 更多