Vscode uses chrome debugging to report an error "cannot access your file" or "localhost rejected our connection request." '

One: the problem

Vscode uses chrome debugging to report an error "cannot access your file" or "localhost rejected our connection request." '

  1. localhost rejected our connection request.
    Insert picture description here
    Corresponds launch.jsonin the configurationsconfiguration to:
        {
    
    
            "name": "Launch index.html",
            "type": "chrome",
            "request": "launch",
            "file": "${workspaceFolder}/index.html"
        },
  1. Unable to access your files
    Insert picture description here
    corresponds launch.jsonin configurationsconfiguration to:
        {
    
    
            "name": "Launch localhost",
            "type": "chrome",
            "request": "launch",
            "url": "http://localhost/mypage.html",
            "webRoot": "${workspaceFolder}/wwwroot"
        },

Two: Solution

The modified configurationsconfiguration items are changed to the following:

  {
    
    
      "name": "使用本机 Chrome 调试",
      "type": "chrome",
      "request": "launch",
       "file": "${file}",
      // "runtimeExecutable": "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe", // 改成您的 Chrome 安装路径
      "sourceMaps": true,
      "webRoot": "${workspaceRoot}",
      "userDataDir":"${tmpdir}",
      "port":9222
  }

Three: effect

After changing according to the above steps, it looks like this:
Insert picture description here
mine is launch.jsonstill configured node调试, select使用本机Chrome调试
Insert picture description here

  • Enter the html file that needs to be debugged,
    Insert picture description here
  • Press F5, the debugging is successful, the problem is solved
    Insert picture description here

Four: Reference

Guess you like

Origin blog.csdn.net/weixin_45844049/article/details/109496158