0

I am trying to run my MEAN app through Visual Code debugger but I cannot start it. It is showing me a Cannot connect to runtime process, timeout after 10000 ms - (reason: Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:58... error. I am running Node 8.1.0 and npm 5.0.3. This is my launch configuration file

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch via NPM",
            "runtimeExecutable": "npm",
            "windows": {
                "runtimeExecutable": "npm.cmd"
            },
            "runtimeArgs": [
                "run",
                "startdev"
            ],
            "port": 5858,
            "protocol": "inspector"
        }
    ]
}

Whenever I execute my program I run it using npm run startdev, startdev being a script in my package.json. How do I start the debugger?

EDIT:

I am running the app using npm run startdev where the startdev is

"startdev": "concurrently \"ng build --watch\" \"cross-env NODE_ENV=development nodemon ./bin/start.js\""

I also tried an attach configuration as such but to no avail

{
     "type": "node",
     "request": "attach",
     "name": "Attach to Process",
     "processId": "${command:PickProcess}",
     "port": 5858
}

1 Answer 1

1

You should use the attach configuration for attaching the debugger to a node process.

You will also need to start the process with the debug flag So something like

node --debug <filename>

Also as pointed out by OP in the comments, debug flag has been deprecated. So use inspect flag.

node --inspect <filename>

The attach configuration looks like { "name": "Attach", "type": "node", "request": "attach", "port": 5858, "address": "localhost", "restart": false, "sourceMaps": false, "outFiles": [], "localRoot": "${workspaceRoot}", "remoteRoot": null }

More about it in the docs here

Sign up to request clarification or add additional context in comments.

4 Comments

Throws the same error. I have updated my question with more details
Just to clarify, you have started the node process with a debug flag right ? It logs to console upon a successful start, something like Debugger listening on [::]:5858 The startdev should be concurrently \"ng build --watch\" \"cross-env NODE_ENV=development nodemon --debug ./bin/start.js\
I get it now. I am running Node 8.1.10 where --debug is deprecated and node is crashing. I had to use --inspect instead. Also outDir is deprecated and outFiles needs to be used as "outFiles": []. If you edit your answer to include these, I will accept it.
Ohh sure.. Let me do that

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.