admin管理员组

文章数量:1122846

I have a simple HTML/JavaScript application that I want to debug in VS Code by attaching to the Chrome instance.

I am using Live Server extension to run the app on port 5500: http://localhost:5500/

I am interested only in the "Attach" setting. Launch is working fine.

In my launch.json file, I have this defined:

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

I added 9222 port to enable remote debugging to Chrome:

C:\Users\MyUsername\AppData\Local\Google\Chrome\Application\chrome.exe --remote-debugging-port=9222

But my breakpoints are not being hit and I get this popup message box:

What's the problem?

I have read similar posts, but have not found a solution.

本文标签: vscode debuggerWhy is Attach to Chrome VS Code debug not workingStack Overflow