【问题标题】:In VS Code, I can't get debugging to work with LiveServer and Firefox / Firefox Developer Edition在 VS Code 中,我无法使用 LiveServer 和 Firefox / Firefox Developer Edition 进行调试
【发布时间】:2021-06-03 22:08:14
【问题描述】:

在 VS Code 中使用 Debugger For Firefox,并在本地主机上为我的 HTML/JS 应用程序运行 LiveServer 实例,在 Firefox 或 Firefox Developer Edition 中打开站点时断点不起作用。

VS 代码为我的项目生成了launch.json 用于在 Firefox 中进行调试,相关部分在这里:

{
    "name": "Launch localhost",
    "type": "firefox",
    "request": "launch",
    "reAttach": true,
    "url": "http://localhost/index.html",
    "webRoot": "${workspaceFolder}"
},

问题是当我运行此设置时,Firefox 找不到该页面,即使找到了,断点也不起作用。但是,上述对 Chrome 的等效项是有效的。

【问题讨论】:

    标签: firefox


    【解决方案1】:

    我通过更改 LiveServer 上的设置解决了这个问题,使其始终在 localhost 端口 8080 上工作,它不会在活动时选择随机端口。这可以通过将以下内容添加到 LiveServer 的 settings.json 文件来完成:

    "liveServer.settings.port": 8080,
    

    在上述问题中包含的 launch.json 代码中,以下行导致了问题:

    "url": "http://localhost/index.html",
    

    这应该是

    "url": "http://localhost:8080",
    

    一旦进行此更改,并且在 this page 的“附加”下建议的所有 Firefox 配置都已完成,并且 LiveServer 对您的项目处于活动状态,调试器应该适用于 Firefox。

    【讨论】:

      猜你喜欢
      • 2018-08-06
      • 2015-05-05
      • 2017-04-25
      • 1970-01-01
      • 2018-08-16
      • 2020-07-13
      • 2015-01-25
      • 2019-05-30
      • 1970-01-01
      相关资源
      最近更新 更多