firefox - 在 Visual Studio Code 中调试时 Firefox 未打开
问题描述
当我使用 Chrome 的启动配置开始调试时,浏览器会打开。但是当我将我的启动配置用于 Firefox 时,浏览器没有打开。不过,Firefox 进程已启动。没有错误消息。
- 视觉工作室代码 1.36.1
- Firefox 1.8.1的调试器
- 火狐 68.0.1
- 视窗 10 1803
- Angular 7.0.0(应该没关系)
.vscode/launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Chrome + localhost",
"url": "http://localhost:4200",
"webRoot": "${workspaceFolder}"
},
{
"type": "firefox",
"request": "launch",
"reAttach": true,
"name": "Firefox + localhost",
"url": "http://localhost:4200",
"webRoot": "${workspaceFolder}"
},
]
}
解决方案
要使用附加模式,您必须从启用了远程调试的终端手动启动 Firefox。请注意,如果您不使用 Firefox 开发者版,则必须先配置 Firefox 以允许远程调试。为此,请打开开发人员工具设置并选中标记为“启用浏览器 chrome 和附加调试工具箱”和“启用远程调试”的复选框(如此处所述)。或者,您可以在 中设置以下值about:config
:
Preference Name Value Comment
devtools.debugger.remote-enabled true Required
devtools.chrome.enabled true Required
devtools.debugger.prompt-connection false Recommended
devtools.debugger.force-local false Set this only if you want to attach VS Code to Firefox running on a different machine (using the host property in the attach configuration)
然后关闭 Firefox 并从这样的终端启动它:
视窗
"C:\Program Files\Mozilla Firefox\firefox.exe" -start-debugger-server
操作系统
/Applications/Firefox.app/Contents/MacOS/firefox -start-debugger-server
Linux
firefox -start-debugger-server
导航到您的 Web 应用程序并使用此 launch.json 配置附加到 Firefox:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch index.html",
"type": "firefox",
"request": "attach"
}
]
}
如果您的应用程序在 Web 服务器上运行,您需要将 url 和 webRoot 属性添加到配置中(如上面的第二个启动配置示例)。
推荐阅读
- blazor - 将带有 html 标签的纯文本转换为 html 字符串并在 Blazor 中呈现
- docker - 启用了*所有*功能的 OpenLiberty Docker 映像
- excel - 如果同一图表私有代码中存在 MouseDown,则 MouseUp 不会触发
- c# - 如果调用方法,则使用我的代码将切换按钮设置为 false
- r - R apply() 函数返回多个元素的列表
- java - 为什么反射 api 在测试用例中不起作用
- ios - HomeKit 委托 API 在 iOS 颤振插件中不起作用
- php - 重写规则 .htaccess 不适用于在 ULR 中获取 PHP 变量
- amcharts - amCharts 带有值的自定义图例(正确的方法和对齐方式)
- java - NullPointerException 尝试检索 @ManyToOne 父字段 - Spring Boot