如何debugging一个运行在Chrome / WebKit上的Node.js服务器作为远程debugging器?
如果你有你的节点运行
node --debug server.js
这给了我一个端口号xxxx,我应该在启动Chrome时使用这个端口号吗?
你是否从Google\ Chrome --remote-debugging-port=xxxx
远程debugging到它 – Google\ Chrome --remote-debugging-port=xxxx
?
或者是9222是一个魔术端口,因为它被提到全部。
我在正确的轨道上,试图用--remote-debugger
启动Chrome到Node.js server.js
节点检查员/ – debugging器现在被检查员replace见下面的更新
#now deprecated / see below for update #install node-inspector npm install -g node-inspector #start node-inspector, listen on port 8080 (default) node-inspector --web-port=8080 #in another terminal session/window: #while node-inspector is running, start your project in debug mode node --debug myproject.js
现在,您可以浏览到http:// your_server:8080,查看myproject.js的完整debugging会话
如果远程服务器由于防火墙或其他原因无法在远程端口上访问,则可以从本地计算机上的端口8080到远程服务器上的“localhost:8080”创build一个ssh-tunnel:
ssh -L 8080:localhost:8080 username@remoteserver -N
并在本地机器上使用http:// localhost:8080的同时继续运行,以debugging远程nodejs会话
更新2017年8月
在检查模式下启动节点:
node --inspect=0.0.0.0:9229 myproject.js
或者如果您希望debugging器在myproject.js的第一行中断:
node --inspect-brk=0.0.0.0:9229 myproject.js
然后在Chrome浏览器中打开以下URL:
chrome://inspect
点击“configuration…”button并添加以下目标:
ip-or-name-of-server-running-node:9229
点击“完成”button后,您应该在远程目标下看到myproject.js。 点击检查链接开始debugging。 不幸的是,检查链接不适用于Ubuntu的Chrome 58。 它适用于Windows的Chrome 60。
使用node-inspector
从Chrome浏览器远程debugging您已经使用--debug
选项开始的节点应用程序,如您所示。
Node(> v6.3.0)和Chrome的最新版本现在允许您使用Chrome开发人员工具来debuggingNode.JS进程,而无需另外安装任何其他程序。 只要通过 – --inspect
node
:
$ node --inspect script.js Debugger listening on port 9229. Warning: This is an experimental feature and could change at any time. To start debugging, open the following URL in Chrome: chrome-devtools://SOME-URL-HERE
只需在Chrome中打开该url,即可开始使用。
如果您需要在节点启动后立即暂停脚本,则还可以在同一命令中传递--debug-brk
。
-
使用$ vagrant ssh – -L 5858:127.0.0.1:5858
to ssh connect to VM. also this comment would start a proxy server on port 5858;
-
您可以使用telnet 127.0.0.1 5858testing本地代理服务器是否启动。
-
在VM中,您可以使用命令启动节点
-
$ node –debug-brk app.js
- 在web风暴中设置debuggingconfiguration。
- 当您在Web风暴中启动debugging时,VM中的node.js服务器将在几秒钟内启动。
PS:没有必要去碰stream浪文件。 参考: 将WebStorm连接到远程的node.jsdebugging会话 。
- React JS:console.debug不是一个函数
- 为什么console.log(10150141932135203)在Firefox和Chrome中打印10150141932135204,以及如何处理这些大整数值?
- 使用来自NodeJs的WebAudio API
- 谷歌铬会话过期=空不工作
- Node.js WebSocket服务器没有收到来自Chrome的正确数据
- websocket的基本authentication
- 由于传输层/元/连接调用,使用faye / nodejs的firefox / chrome的长时间初始页面加载
- 仅在Chrome中使用超慢速预检选项
- 为什么我在node.js中使用parseInt得到奇怪的结果? (与Chrome js控制台不同的结果)