Home > database >  VSCode adn Javascript: cannot connect to the target at localhost:9222
VSCode adn Javascript: cannot connect to the target at localhost:9222

Time:11-04

I am trying to follow debugging setup for Javascript from VSCode website https://code.visualstudio.com/docs/nodejs/browser-debugging#_open-link-command This is missing a lot of information, when I try to copy the launch.json Configuration from the website, I get the error VSCode and Javascript: cannot connect to the target at localhost:9222 If I use my own launch.json configuration, I cannot hit any of the breakpoints, the breakpoints all turn into white circles while debugging

First question: Why is URL pointing to "http://localhost:8080"? Does VSCode automatically launch a server? Do I need to download an extension for this? Whereas in the first configuration, "http://localhost/test/index.html" is pointing to my XAMPP server

Second Question: Looks like it's not starting edge with debugging enabled, where in VSCode can I add this line? edge.exe --remote-debugging-port=9222 --user-data-dir=remote-debug-profile is it not automatically started with this? Can I specify the edge executable path in launch.json?

Third Question: I also tried adding the absolute path of edge with this property "runtimeExecutable" : "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe --remote-debugging-port=9222 --user-data-dir=remote-debug-profile" and changing from attach to launch but I get the error unable to launch browser, available auto-discovered versions are ["stable"] how do I enter the exact path and arguments here?

My Launch.json is below that does not allow breakpoints to be hit

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "msedge",
            "request": "launch",
            "name": "Launch Edge Against Localhost",
            "url": "http://localhost/test/index.html",
            "webRoot": "${workspaceFolder}"
            }
        }
    ]
}

Launch.json From VSCode website that causes the error

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "msedge",
            "request": "attach",
            "name": "Attach to browser",
            "port": 9222,
            "url": "http://localhost:8080",
            "webRoot": "${workspaceFolder}"
        }
    ]
}

index.html is below

<head>
    <title>Read Text File</title>
    <link rel="stylesheet" href="main.css">
</head>

<body>
    <div id="myDynamicTable"></div>
    <script>

         window.onload = () => {
              document.write("TEST:");
         }
    </script>  
</body>

CodePudding user response:

Have you installed node.JS?

000000000000000000000000000

000000000000000000000000000

  • Related