来自Vagrant的节点调试

Geo*_*hey 5 debugging remote-debugging node.js vagrant

无法从主机远程调试Chrome中Vagrant框上运行的节点服务器.服务器配置为在端口8123上运行.

节点版本:7.10.0

在Vagrantfile中:

config.vm.network :forwarded_port, host: 9229, guest: 9229
config.vm.network :forwarded_port, host: 8123, guest: 8123
Run Code Online (Sandbox Code Playgroud)

从我的流浪盒我运行:

$ node --inspect index.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://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:9229/84085f07-dc42-4e1e-bdd8-532e6dc5c4c6
--- Customer Service---
Connecting to customer repository...
Connected. Starting server...
Server started successfully, running on port 8123.
Run Code Online (Sandbox Code Playgroud)

当我尝试从主机访问Chrome中的网址而我没有收到错误时,"来源"标签为空.

devTools的屏幕截图

dhi*_*ilt 6

基于NodeJS 11591 问题。您无法通过 localhost (127.0.0.1) 访问 Vagrant 内容,因此您需要明确指定主机:

$ node --inspect=0.0.0.0:9229 index.js

然后您需要在 Chrome 中设置目标发现设置。请注意,192.168.33.11在我的示例中,静态 IP 地址提供了从本地主机访问 Vargant 主机的权限:

在此处输入图片说明

  • 尝试转发另一个端口,例如 9228。看起来某个进程处理它。 (2认同)