在vs代码中,我在HTML angularjs项目中创建了一个launch.json
文件。我无法在本地主机中启动该项目。它继续说Failed to load resource: net::ERR_CONNECTION_REFUSED (http://localhost:8080/)
。
项目结构: -
Project => .vscode => launch.json
=> app
=> scripts
=> styles
=> index.html
launch.json: -
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Chrome against localhost, with sourcemaps",
"type": "chrome",
"request": "launch",
"url": "http://localhost:8080",
"sourceMaps": true,
"webRoot": "${workspaceRoot}"
},
{
"name": "Attach to Chrome, with sourcemaps",
"type": "chrome",
"request": "attach",
"port": 9222,
"sourceMaps": true,
"webRoot": "${workspaceRoot}"
}
]
}
有人可以帮我解决这个问题吗?提前致谢
答案 0 :(得分:1)
我遇到了同样的问题。
将launch.json文件更改为以下内容可以解决此问题(Chrome是我的默认浏览器):
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "pwa-node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}\\app.js"
}
]
}
app.js在我的工作区的根文件夹中。
以下是主要的launch.json文件:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}
答案 1 :(得分:0)
只需将您的设置更改为launch.json
即可{ &#34;版本&#34;:&#34; 0.2.0&#34;, &#34;配置&#34;:[ { &#34; name&#34;:&#34;针对localhost启动Chrome&#34;, &#34;输入&#34;:&#34; chrome&#34;, &#34;请求&#34;:&#34;启动&#34;, &#34; url&#34;:&#34; http://localhost:4200&#34;, &#34; webRoot&#34;:&#34; $ {workspaceRoot}&#34; }, { &#34; name&#34;:&#34;附加到Chrome&#34;, &#34;输入&#34;:&#34; chrome&#34;, &#34;请求&#34;:&#34;附加&#34;, &#34; port&#34;:4200, &#34; webRoot&#34;:&#34; $ {workspaceRoot}&#34; } ] }