table of Contents
One: the problem
Vscode uses chrome debugging to report an error "cannot access your file" or "localhost rejected our connection request." '
- localhost rejected our connection request.
Correspondslaunch.json
in theconfigurations
configuration to:
{
"name": "Launch index.html",
"type": "chrome",
"request": "launch",
"file": "${workspaceFolder}/index.html"
},
- Unable to access your files
correspondslaunch.json
inconfigurations
configuration to:
{
"name": "Launch localhost",
"type": "chrome",
"request": "launch",
"url": "http://localhost/mypage.html",
"webRoot": "${workspaceFolder}/wwwroot"
},
Two: Solution
The modified configurations
configuration 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:
mine is launch.json
still configured node调试
, select使用本机Chrome调试
- Enter the html file that needs to be debugged,
- Press
F5
, the debugging is successful, the problem is solved