Chrome 中的 VS Code 调试 - 无法访问此站点错误 [英] VS Code debug in Chrome - This site can’t be reached error

查看:52
本文介绍了Chrome 中的 VS Code 调试 - 无法访问此站点错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道以前有人问过这个问题,但是在阅读了很多帖子之后,我仍然没有找到答案...

我正在尝试使用 Chrome 调试一个非常简单的 html 应用程序,但是当我到达我的本地主机时,我收到一条错误消息,指出无法访问此站点".我的 launch.json 代码如下所示:

"version": "0.2.0",配置":[{"name": "使用源映射针对本地主机启动 Chrome",类型":铬",请求":启动","url": "http://localhost:3000","sourceMaps": 真,"webRoot": "${workspaceRoot}"},{"name": "附加到 Chrome,带有源地图",类型":铬","请求": "附加",端口":9222,"sourceMaps": 真,"webRoot": "${workspaceRoot}"}]}

任何帮助都将不胜感激,因为我已经为此苦苦挣扎了一段时间.

解决方案

正如@Rob-Lourens 提到的,您需要启动自己的本地服务器来托管您的 HTML/Javascript/CSS 和图像.

您可以使用 VS 代码插件

I know this question has been asked before, but after reading a lot of the threads, I still haven't found my answer...

I am trying to debug a very simple html app with Chrome, but when I get to my localhost I get an error that says "This site can’t be reached". My launch.json code looks like this:

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

]
}

Any help would really be appreciated as I have been struggling for quite a while with this now.

解决方案

As @Rob-Lourens has mentioned you need to start your own local server to host your HTML/Javascript/CSS and images.

You can use a VS code plugin Live Server to create a local development server for you. Please make sure your URL("url": "http://localhost:3000") in your configuration file matches the URL of Live Server.

If you are on Windows and want to use IIS or IIS Express you can read up on IIS and IISExpress

这篇关于Chrome 中的 VS Code 调试 - 无法访问此站点错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆