4

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

monstro
  • 6,254
  • 10
  • 65
  • 111
  • 1
    The readme includes a whole section on this error: https://github.com/Microsoft/vscode-chrome-debug#cannot-connect-to-the-target-connect-econnrefused-1270019222. However, I strongly recommend using the 'launch' config - it's much easier! – Rob Lourens Aug 26 '17 at 19:47
  • Its not easier when you are building apps to work with Google API, it will open a new Chrome window and will ask for Google account authentication and authorization (email & password) every time you run it. This doesn't happen when it opens it in a new tab. – monstro Aug 27 '17 at 11:06
  • Hm, I would think it would persist after you've logged in once. Maybe not. – Rob Lourens Aug 28 '17 at 14:20
  • 1
    this is a great tutorial http://kynatro.com/blog/2018/01/11/chrome-debugging-in-vscode/ make sure no other chrome instances or working and also that you are on the exact url as you state in the url field (and it's open in the browser) – shahar taite Nov 13 '18 at 16:55

1 Answers1

1

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

See my answer here for more details.

benshabatnoam
  • 7,161
  • 1
  • 31
  • 52
  • This did not work for me. Getting the error, could not find any debuggable target a tlocalhost:3000 . < my app is running at port 3000> – etotientz Apr 01 '22 at 04:34