无法从我的主机远程调试在 Chrome 中的 Vagrant box 上运行的 Node 服务器。服务器配置为在端口 8123 上运行。
Node 版本:7.10.0
在 Vagrantfile 中:
config.vm.network :forwarded_port, host: 9229, guest: 9229
config.vm.network :forwarded_port, host: 8123, guest: 8123
我从我的 vagrant box 运行:
$ 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.
当我尝试从我的主机访问 Chrome 中的 url 而我没有收到错误消息时,源选项卡是空的。
最佳答案
基于 NodeJS 11591 issue .您无法通过本地主机 (127.0.0.1) 访问 Vagrant 内容,因此您需要明确指定主机:
$ node --inspect=0.0.0.0:9229 index.js
然后您需要在 Chrome 中设置目标发现设置。请注意,我的示例中的 192.168.33.11
是提供从本地主机访问 Vargant 主机的静态 IP 地址:
关于node.js - 来自 Vagrant 的 Node 调试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43796371/