NukPan
NukPan

Reputation: 319

In VS Code, I can't get debugging to work with LiveServer and Firefox / Firefox Developer Edition

Using Debugger For Firefox in VS Code, and running an instance of LiveServer for my HTML/JS application on localhost, breakpoints do not work when opening the site in Firefox or Firefox Developer Edition.

VS code has generated the launch.json for debugging in Firefox for my project, with the relevant part here:

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

The issue is that when I then run this setup, Firefox cannot find the page, and even if it does, breakpoints do not work. The equivalent of the above for Chrome works, however.

Upvotes: 0

Views: 1091

Answers (1)

NukPan
NukPan

Reputation: 319

I resolved this issue by changing the settings on LiveServer so that it always works on localhost port 8080, it won't just chose a random port when its active. This can be done by adding the following to LiveServer's settings.json file:

"liveServer.settings.port": 8080,

In the launch.json code included in the above question, the following line is causing the issue:

"url": "http://localhost/index.html",

This should instead be

"url": "http://localhost:8080",

Once this change is made, and all the Firefox configurations suggested under 'Attach' on this page are made and LiveServer is active for your project, the debugger should work for Firefox.

Upvotes: 2

Related Questions