2014-01-26 37 views
10

我想調試我的sails.js應用程序,但我不知道如何在這種情況下啓動node-inspector如何在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此錯誤:

如果我錯了0
Error: read ECONNRESET. Check there is no other debugger client attached to port 1337. 
+0

可能的重複[如何在Windows上調試基本node.js應用程序(而不是http)](http://stackoverflow.com/questions/11437958/how-to-debug-a-basic-node-js- application-not-http-on-windows) –

回答

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。節點檢查器Web默認在端口8080上運行,而調試器鏈接在端口5858上運行。

+0

如果在sails中有一個可用的標誌來啓用調試模式,那將是非常棒的。我會去捅一下。 – gorelative

11

從Sails 0.9.8開始,您可以使用sailsd在調試模式下調用風帆,例如, sailsd lift

- 編輯 -

看起來這實際上並沒有使它成爲0.9.8,是我不好。爲了使自己的調試命令現在,保存以下爲/usr/local/binsailsd(或任何你喜歡):

#!/bin/sh 
node --debug `which sails` [email protected] 

- 編輯2 -

在帆v0.10.x,你可以執行sails debug而不是sails lift以調試模式啓動Sails!

+0

我在我的系統上找不到'sailsd'。 – Patryk

+0

我的壞 - 我以爲我們已經把它放到了0.9.8。有關如何創建'sailsd'的信息編輯。 – sgress454

+0

v10文檔:https://github.com/balderdashy/sails-docs/blob/master/reference/Command%20Line/sailsdebug.md – dbasch