我想调试我的sails.js应用程序,但我不知道如何为此场合启动node-inspector
。
通常它会:
$ node --debug myapp.js
如果我正常运行我的风帆应用程序:
$ 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.
答案 0 :(得分:11)
从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!
答案 1 :(得分:6)
如果我错了,请纠正我但是,如果帆在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
编辑刚刚确认此方法有效,而不是使用sails lift
您正在使用节点以调试模式启动app.js
。 node-inspector web在端口8080
上运行,调试器默认在端口5858
上链接。