Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firefox does not open when debugging in Visual Studio Code

When I start debugging with my launch configuration for Chrome, the browser opens. But when I use my launch configuration for Firefox, the browser does not open. A Firefox process is started though. There are no error messages.

  • Visual Studio Code 1.36.1
  • Debugger for Firefox 1.8.1
  • Firefox 68.0.1
  • Windows 10 1803
  • Angular 7.0.0 (should not matter)

.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}"
      },
    ]
  }
like image 666
Marco Eckstein Avatar asked Jul 29 '19 21:07

Marco Eckstein


People also ask

How do I enable debugging in Visual Studio code?

To run or debug a simple app in VS Code, select Run and Debug on the Debug start view or press F5 and VS Code will try to run your currently active file. However, for most debugging scenarios, creating a launch configuration file is beneficial because it allows you to configure and save debugging setup details.

How do I change the debug browser code in Visual Studio?

Alternatively, you can also use the Visual Studio Code command palette and run the “Debug: Open Link” command. From there on you can choose to debug in Chrome, Edge or Node.

How do I debug Firefox in Visual Studio Code?

In Visual Studio, select Debug -> Other Debug Targets -> Debug Installed App Package. In the dialog, select the installed Firefox package you wish to debug and click “Start”. Please refer to this. VC++ 6.0: To change or set the executable to debug, go to Project > Settings…, Debug tab and select General from the drop down list.

How to choose which browser to debug with in Visual Studio?

Tip: Choose which browser to debug with in Visual Studio 1 Right-click your start-up project in Studio and click Browse With… 2 Click Add 3 Click the Browse button beside Program Name 4 Select the browser you wish to use 5 Click Ok 6 Select the browser you just added and click Set as Default More ...

How do I enable remote debugging If I don't use Firefox?

Note that if you don't use Firefox Developer Edition, you must first configure Firefox to allow remote debugging. To do this, open the Developer Tools Settings and check the checkboxes labeled "Enable browser chrome and add-on debugging toolboxes" and "Enable remote debugging" (as described here).

How to debug a start-up project in Visual Studio?

By default, Visual Studio uses Internet Explorer for debugging. If you’re looking for a way to change that, perhaps to harness the power of developer tools in Firefox or other browsers (or perhaps just because you don’t like IE), it’s pretty easy to do. Right-click your start-up project in Studio and click Browse With…


1 Answers

To use attach mode, you have to launch Firefox manually from a terminal with remote debugging enabled. Note that if you don't use Firefox Developer Edition, you must first configure Firefox to allow remote debugging. To do this, open the Developer Tools Settings and check the checkboxes labeled "Enable browser chrome and add-on debugging toolboxes" and "Enable remote debugging" (as described here). Alternatively you can set the following values in 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)

Then close Firefox and start it from a terminal like this:

Windows

"C:\Program Files\Mozilla Firefox\firefox.exe" -start-debugger-server

OS X

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

Linux

firefox -start-debugger-server

Navigate to your web application and use this launch.json configuration to attach to Firefox:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch index.html",
            "type": "firefox",
            "request": "attach"
        }
    ]
}

If your application is running on a Webserver, you need to add the url and webRoot properties to the configuration (as in the second launch configuration example above).

like image 129
N. Richli Avatar answered Sep 19 '22 16:09

N. Richli