Slava
Slava

Reputation: 6650

Error trying to debug in VSCode with "Attach to Chrome" option using Debugger For Chrome plugin

Visual Studio Code.
Typescript files are compiled to JavaScript files with sourcemaps. Generated launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "chrome",
            "request": "launch",
            "name": "Launch Chrome against localhost",
            "url": "http://localhost:8080",
            "webRoot": "${workspaceRoot}"
        },
        {
            "type": "chrome",
            "request": "attach",
            "name": "Attach to Chrome",
            "port": 9222,
            "webRoot": "${workspaceRoot}"
        }
    ]
}

Chrome is started with parameter: --remote-debugging-port=9222

enter image description here

However I still get

Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:9222

error in VSCode, when trying to debug with "Attach to Chrome" option.

enter image description here

Upvotes: 4

Views: 7180

Answers (2)

ShinobiWPS
ShinobiWPS

Reputation: 11

I wanted to achieve the same and tried the same without success but i found a different way. Assuming you want to have the same browser session of your default one you can modify your launch.json to:

 {
  "configurations": [
    {
      "type": "chrome",
      "request": "launch",
      "name": "Launch Chrome against localhost",
      "url": "http://localhost:5173",
      "webRoot": "${workspaceFolder}",
      "userDataDir": false // <--
    }
  ]
}

You will get a new Chrome window but using your default Chrome profile (with all the extensions, bookmarks, etc..) with the debugging capabilities you were looking for.

Upvotes: 0

benshabatnoam
benshabatnoam

Reputation: 7680

Using 'urlFIlter' with * as wildcard will fix your problem.

See my answer here for more details.

Upvotes: 1

Related Questions