user2510058
user2510058

Reputation: 538

Visual studio code, debug not working

Hello i have problem with debug my app of node and visual studio code. When i tried run debug in visual i saw text " Debugger listening on port 30108 " but when i open my browser on localhost:30108 there is only information somethig like this

Type: connect
V8-Version: 4.5.103.36
Protocol-Version: 1
Embedding-Host: node v4.4.7
Content-Length: 0

on localhost:3000 (default app port) there is only error " This site is unreachable " So how to do, to be able to debug app with running app in browser ?

Upvotes: 1

Views: 2839

Answers (1)

t.j.
t.j.

Reputation: 1337

If you do a node app.js or npm start (or whatever for your project) in a terminal/command window, does your project also start successfully? Which OS are you using? Any firewall issues going on?

If you can access the site in your browser outside of VS Code, check my "Third attempt" documented here. Essentially, you need to edit both your launch.json and your package.json to indicate the port you are going to use. My examples follow the npm run {script name} format. You should be able to tailor it to suit.

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "cwd": "${workspaceRoot}",
            "runtimeExecutable": "npm.cmd",
            "runtimeArgs": [
                "run", "start"
            ],
            "port": 5858,
            "skipFiles": [
                "<node_internals>/**/*.js"
            ]
        }
    ]
}

package.json

"scripts": {
  "start": "node --inspect=5858 src/app.js",
}

Essentially, you need to ensure you are launching your app the same way you would from the command line. Then, ensure you have the matching port info in both files (and their respective locations) mentioned above.

More info available here for alternate/additional configuration options for debugging.

Upvotes: 1

Related Questions