I have searched and searched and searched for days. I am at my wits end so please be patient with me. I am very new at this.
I have tried almost all suggestions on the net, to no avail.
When I try to launch launch.json in VS Code it goes straight to "localhost refused to connect" page. When I launch it via command line using "npm start", it is successful and no issues are found.
This is my launch.json file:
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"timeout": "10000",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}`
When I try to add the following line to the configurations in launch.json:
"preLaunchTask": "npm: start"
It somewhat works. The page displays the content on localhost, but the debugger continues to load indefinitely, leaving me unable to press the green arrow to do it again. I have to go to the terminal in VS Code and "control + c" to shut it down but in doing so VS Code launches another localhost that refused to connect, at which point I can press run again to another successful page that seemed to have completely loaded.
At the same time it displays "localhost refused to connect" this displays in the debug console: "crbug/1173575, non-JS module files deprecated. ...mewebdata/(index)꞉6567:22:6792". This occurs when I remove the
"preLaunchTask": "npm: start"
from the launch.json file.
I have tried installing Live Server and running on localhost:5500 but it only gives me a directory of my files and not the actual content itself. I tried creating a tasks.json and a settings.json file. Nada. I've tried the ipconfig /flushdns equivalent on Mac. Nope.
I would rather not do it any of these ways. I want to press the run button and have Chrome open a localhost of my code successfully. That's all. What is missing here?
EDIT: I keep getting the error "Chrome didn't shut down properly" every time I run with the offer of restoring my page. I click the X in the top left corner to exit. Is that not what I'm supposed to do?