如何调试使用Chrome/WebKit作为远程调试器运行的Node.js服务器?
如果您的节点正在运行如何调试使用Chrome/WebKit作为远程调试器运行的Node.js服务器?,node.js,google-chrome,webkit,Node.js,Google Chrome,Webkit,如果您的节点正在运行 node --debug server.js 这给了我一个端口号xxxx,我应该在启动Chrome时使用这个端口号吗 您是否从Google\Chrome--远程调试端口=xxxx进行远程调试 或者是9222是一个神奇的端口,因为它被提到了所有 我是否在正确的轨道上,尝试使用--remote debugger启动Chrome进入Node.jsserver.js用于从Chrome远程调试节点应用程序,您已经使用--debug选项启动,如图所示。v6.3.0)和Chrome的最
node --debug server.js
这给了我一个端口号xxxx,我应该在启动Chrome时使用这个端口号吗
您是否从Google\Chrome--远程调试端口=xxxx
进行远程调试
或者是9222是一个神奇的端口,因为它被提到了所有
我是否在正确的轨道上,尝试使用--remote debugger
启动Chrome进入Node.jsserver.js
用于从Chrome远程调试节点应用程序,您已经使用--debug
选项启动,如图所示。- 使用
$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;
参考:.节点检查器/--debug现在被检查器替换 请参阅下面的更新
#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
现在,您可以浏览到以获取myproject.js的完整调试会话
如果由于防火墙或其他原因无法在远程端口上访问远程服务器,则可以创建一个ssh隧道,从本地计算机上的端口8080到远程服务器上的“localhost:8080”:
ssh -L 8080:localhost:8080 username@remoteserver -N
并在本地计算机上调试远程nodejs会话时保持此功能运行
2017年8月更新 在检查模式下启动节点:
node --inspect=0.0.0.0:9229 myproject.js
或者,如果希望调试器在myproject.js的第一行中断:
node --inspect-brk=0.0.0.0:9229 myproject.js
然后在chrome浏览器中打开以下URL:
chrome://inspect
单击“配置…”按钮并添加以下目标:
ip-or-name-of-server-running-node:9229
单击“完成”按钮后,应该会在远程目标下看到myproject.js。单击inspect链接开始调试。不幸的是,inspect链接无法在Chrome58上运行。它可以在Chrome 60 for Windows上正常工作。Node(>v6.3.0)和Chrome的最新版本现在允许您使用Chrome Developer工具,而无需安装任何其他工具。只需将--inspect
传递到节点
:
$ 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
。您知道运行meteor服务器时是否必须像您的示例中那样显式启动节点检查器吗?谢谢!使用chrome://inspect/
,但是VS代码(附加但断点不起作用)和IntelliJ IDEA(打印“连接到ip…”)失败,其他情况不会发生。对于永久检查和保存时重新加载,请使用此forever-w-c'节点--inspect=127.0.0.1:3333'file.js