我的配置和工作流程。
附注我在about:config 中更新了 Firefox 配置,但没有像 Google Chrome 那样获得所需的简单结果。
我安装了以下浏览器(Ubuntu 20.04 x64):
-
Firefox 用于 Ubuntu 94.0
-
Google Chrome 版本 96.0.4664.45(官方版本)(64 位)
-
Microsoft Edge 版本 96.0.1054.34(官方版本)测试版(64 位)
对于所有浏览器,我没有更改它们的配置。
我的调试扩展(只有一个):Debugger for Firefox。
我的 VS 代码:
Version: 1.62.3
Commit: ccbaa2d27e38e5afa3e5c21c1c7bef4657064247
Date: 2021-11-17T08:00:36.721Z
Electron: 13.5.2
Chrome: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Linux x64 5.11.0-40-generic
配置
{
"configurations": [
{
// Start Debug -> Open Firefox, Open Debug console, Click an line in JS File and F5
"type": "firefox",
"request": "launch",
"reAttach": true,
"name": "Firefox + File",
"file": "${file}"
},
{
// Start Debug -> Open Firefox, Open Debug console, Click an line in JS File and F5
"type": "firefox",
"request": "launch",
"reAttach": true,
"name": "Firefox + Server",
"url": "http://localhost:8080/${fileBasename}",
// "url": "http://localhost:8080/index.html",
"webRoot": "${workspaceFolder}/public/"
}
{
"type": "pwa-chrome",
"name": "Chrome + File",
"request": "launch",
"file": "${file}"
},
{
"type": "pwa-chrome",
"name": "Chrome + Server",
"request": "launch",
"url": "http://localhost:8080/${fileBasename}",
// "url": "http://localhost:8080", // the index file
"webRoot": "${workspaceFolder}/public"
},
{
"name": "Edge + Server",
"request": "launch",
"type": "pwa-msedge",
"url": "http://localhost:8080/${fileBasename}",
// "url": "http://localhost:8080",
"webRoot": "${workspaceFolder}/public",
"runtimeExecutable":"/opt/microsoft/msedge-beta/msedge"
}
]
}
我可以将我的index.html 和其他 html 文件作为本地文件和服务器页面运行在公共目录中。在我的服务器上,该文件位于public 目录中。我从公共目录所在的根目录工作。
我只有 Firefox 才有一些不愉快的问题。现在它适用于以下解决方法和上述配置。
在 Firefox 中开始调试的步骤:
- 使用提供的配置,我们可以根据需要更改路径或文件。 https://code.visualstudio.com/docs/editor/variables-reference 但对我来说,当我在 URL 中使用指定文件时,它可以工作,例如,
/index.html。
- 开始调试(选择配置并按F5)。
- Firefox 已打开,但调试仍未成功。
- 打开开发工具 (F12)。 是的,没有它调试对我不起作用。
- 重新加载页面(在浏览器中按 F5 或在您的操作系统中按 Ctrl+R 或其他组合键)。
- 已使用您的断点开始调试。
我收到了 VS Code 的以下消息,但它在没有额外路径的情况下工作:
此文件的路径未映射到 Firefox 加载的任何 url。 Firefox 尚未加载此文件,或者您的调试配置需要此文件的路径映射 - 您是否认为该文件已加载并希望路径映射向导尝试为您创建路径映射?
我对 Microsoft Edge 浏览器进行了一些修复。我设置了浏览器bin文件的路径:"runtimeExecutable":"/opt/microsoft/msedge-beta/msedge".