首页 > 解决方案 > 如何使用 VSCode 在 Firefox 中保留扩展并请求启动

问题描述

我正在尝试使用 React Dev Tools 和 Firefox Developer Edition 调试 React 应用程序。我无法将 React Dev Tools 安装到 Firefox 通过 VSCode 启动时使用的配置文件。当我通过在 /Applications 中打开 Firefox 自己启动 Firefox 时,我已经安装了 React Dev Tools。

但是,当我运行以下launch.json配置文件时,启动后,Preferences -> Extensions & Themes -> Extensions in FireFox 下没有显示扩展。

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

但是,我可以按照此处的说明使用终端启动 Firefox 并将调试器附加到它。此配置文件具有 React 开发工具,并且运行良好:

/Applications/Firefox\ Developer\ Edition.app/Contents/MacOS/firefox -start-debugger-server

启动.json:

{
  "name": "Attach",
  "type": "firefox",
  "request": "attach",
  "url": "http://localhost:3000",
  "webRoot": "${workspaceFolder}"
},

但是我如何使第一个与launch请求而不是一起工作attach?从阅读它似乎与配置文件有关

标签: reactjsfirefoxvisual-studio-codereact-devtools

解决方案


我遇到了同样的问题,并且能够通过添加到我的 launch.json 来解决它:

"profile": "my-firefox-profile"

Firefox 可以安装多个配置文件。您可以通过输入about:profilesFirefox 地址栏来检查它们。它将向您显示配置文件列表。标记为的Default profile: yes应该是可以选择的。

在此处输入图像描述

我的 launch.json 现在看起来像这样:

    {
        "name": "Firefox",
        "type": "firefox",
        "request": "launch",
        "reAttach": true,
        "url": "http://localhost:4300",
        "webRoot": "${workspaceFolder}",
        "profile": "default-release-1"
    },

背景:

Firefox 配置文件包含浏览历史记录、书签等设置 - 最重要的是 - 附加组件。通过告诉 VSCode 使用它与已安装插件一起提供的特定配置文件。

如果您对 Angular 或 Vue 有同样的问题,这也将起作用。


推荐阅读