【问题标题】:Node Debug From Vagrant来自 Vagrant 的节点调试
【发布时间】:2017-10-03 10:18:20
【问题描述】:

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

节点版本:7.10.0

在 Vagrantfile 中:

config.vm.network :forwarded_port, host: 9229, guest: 9229
config.vm.network :forwarded_port, host: 8123, guest: 8123

我从我的流浪盒子里跑:

$ 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 而我没有收到错误时,源选项卡是空的。

Screenshot of devTools

【问题讨论】:

  • Chrome 中的网址是否适合您设置的网络?
  • 是的。我使用了命令输出指定的URL

标签: node.js debugging vagrant remote-debugging


【解决方案1】:

基于NodeJS 11591 issue。你不能通过 localhost (127.0.0.1) 访问 Vagrant 的东西,所以你需要明确指定主机:

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

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

【讨论】:

  • 仍然出现此错误:This site can’t be reached The webpage at ws://0.0.0.0:9229/ might be temporarily down or it may have moved permanently to a new web address. ERR_DISALLOWED_URL_SCHEME
  • 我已更新答案以提供更多详细信息。这就是它对我的工作方式。
  • 在 0.0.0.0:9229 上启动检查器失败:地址已在使用中
  • 尝试转发另一个端口,例如9228. 看起来有些进程处理它。
  • 还是一样的The webpage at ws://0.0.0.0:9228/cea5114d-29c9-4561-a700-3a992cb08b7e might be temporarily down or it may have moved permanently to a new web address. ERR_DISALLOWED_URL_SCHEME
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-02-18
  • 2018-08-28
  • 2020-04-05
  • 2021-06-18
  • 2019-03-15
  • 1970-01-01
  • 2014-02-14
相关资源
最近更新 更多