Node.js:如何远程debugging?

我有一个Linux服务器(操作系统:CentOS,IP:192.168.1.100)与我想要debugging的节点应用程序。
出于某种原因,我必须在远程客户端(ip:192.168.1.7)上工作,因为Linux服务器没有GUI /浏览器。

我没有按照说明使用节点检查器,没有成功…

这是我做的:

$ npm --version 2.14.2 $ node --version v4.0.0 $ npm install -g node-inspector $ node-inspector --version Node Inspector v0.12.3 $ node-debug myApp.js Node Inspector is now available from http://127.0.0.1:8080/?ws=127.0.0.1:8080&port=5858 Debugging `myApp.js` Debugger listening on port 5858 

然后,如果我打开我的客户端浏览器到http://127.0.0.1:8080/?ws=127.0.0.1:8080&port=5858 ,我得到错误ERR_ADDRESS_UNREACHABLE

如果我打开我的客户端浏览器到http://192.168.1.100:8080/?ws=192.168.1.100:8080&port=5858相同的结果。

如果(出于好奇)我打开http://192.168.1.100:5858我只是得到:

 Type: connect V8-Version: 4.5.103.30 Protocol-Version: 1 Embedding-Host: node v4.0.0 Content-Length: 0 

我已经在我的防火墙上打开了端口8080和5858(在安全方面)(在/etc/sysconfig/iptables我有:

 ... -A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 5858 -j ACCEPT ... 

)。

我错过了什么?


更新 :在@aleungbuild议之后,我在node-debug命令行中添加了web-host=0.0.0.0标志,但没有成功:我总是在浏览器中获得ERR_ADDRESS_UNREACHABLE 。 即使telnet 192.168.1.100 8080192.168.1.7客户端超时。 而是,一个telnet 192.168.1.100 5858答案:

 Type: connect V8-Version: 4.5.103.30 Protocol-Version: 1 Embedding-Host: node v4.0.0 Content-Length: 0 

这可能意味着debugging器正在监听,但仍然无法从客户端界面访问:-(

默认情况下,node-inspector web服务器在127.0.0.1上侦听,只接受来自localhost的连接。 您必须使用选项--web-host=0.0.0.0在服务器上启动节点检查器:

 $ node-debug --web-host 0.0.0.0 myApp.js 

然后打开你的客户端浏览器到http://server:8080/?ws=server:8080&port=5858 ,其中服务器是你的服务器IP。

节点7.x

节点–inspect:file_name