0

I have project structure as shown below. Through command line we use make run to start the execution but need to debug by using breakpoints in it. So how to setup in vsc.

enter image description here

Below is my launch.json file

{
    "version": "0.2.0",
    "configurations": [
    {
        "type": "node",
        "request": "attach",
        "name": "Attach",
        "port": 9229
    },
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceRoot}/make",
            "args": [
                "run"
            ]
        }
    ]
}

This doesn't work but how to setup.

1 Answer 1

1

Go here first: enter image description here

In the drop down above select Add configuration and select Node. THen add this in the launch.json file which opens up for you:

{
    // Use IntelliSense to learn about possible Node.js debug 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": "node",
            "request": "launch",
            "name": "Project Name Here",
            "program": "${workspaceRoot}/src\\server\\changeToYourAppFile.js",
            "cwd": "${workspaceRoot}",
            "restart": true,
            "protocol": "inspector"
        }
    ]
}

The following is my app file:

server = app.listen(port, err => {
    if (err) { return console.error(err); }
    console.info('==> ✅ 💻 Express server is listening');
    console.info(`==> 🌎 😃 Go to http://localhost:${port} [${env}]`);
});

server.timeout = 3600000;
Sign up to request clarification or add additional context in comments.

4 Comments

make sure that the port number specified in your project is not already in use. If you are using webpack-dev-server make sure you stop that. If you are using PM2 then kill the pm2 instance and do this.
I don't have a js file to be invoked like you have mentioned in configurations.program. I have a make file so I need to run make run
Yeah. you do that and then put the server start code o'er there. Give this file's path in the launch.json then
Its not as simple as you have mentioned the server start code. Its configured differently. So that's the reason I was asking how to execute make run command from VSC

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.