Mar*_*ein 9 firefox visual-studio-code vscode-debugger
当我开始使用 Chrome 的启动配置进行调试时,浏览器将打开。但是当我使用 Firefox 的启动配置时,浏览器无法打开。但 Firefox 进程已启动。没有错误消息。
.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}"
},
]
}
Run Code Online (Sandbox Code Playgroud)
小智 7
要使用附加模式,您必须从启用了远程调试的终端手动启动 Firefox。请注意,如果您不使用 Firefox Developer Edition,则必须首先配置 Firefox 以允许远程调试。为此,请打开开发人员工具设置并选中标有“启用浏览器镶边和附加调试工具箱”和“启用远程调试”的复选框(如此处所述)。或者,您可以在 中设置以下值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)
Run Code Online (Sandbox Code Playgroud)
然后关闭 Firefox 并从终端启动它,如下所示:
视窗
"C:\Program Files\Mozilla Firefox\firefox.exe" -start-debugger-server
Run Code Online (Sandbox Code Playgroud)
操作系统
/Applications/Firefox.app/Contents/MacOS/firefox -start-debugger-server
Run Code Online (Sandbox Code Playgroud)
Linux
firefox -start-debugger-server
Run Code Online (Sandbox Code Playgroud)
导航到您的 Web 应用程序并使用此 launch.json 配置附加到 Firefox:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch index.html",
"type": "firefox",
"request": "attach"
}
]
}
Run Code Online (Sandbox Code Playgroud)
如果您的应用程序在 Web 服务器上运行,则需要将 url 和 webRoot 属性添加到配置中(如上面的第二个启动配置示例)。
| 归档时间: |
|
| 查看次数: |
18807 次 |
| 最近记录: |