skip to Main Content

I am using VS Code 1.79.2, and I am trying to Debug a Node.js file, which is named Index-multiclient.js, which is acting as a WebSocket Server.

I cannot figure out what I need to do to run it in Debug Mode.

My version of VS Code does not seem to match the Tutorials I found on YouTube.
My Launch.json file looks as follows:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "launch Program",
            "type": "node",
            "request": "launch",
        }
    ]
}

If I go to RUN AND DEBUG, I am presented with "launch Program", and I don’t know what to hit next.

2

Answers


  1. Your launch config is missing the "program" property where you pass the path to the script file you want to run with NodeJS. Ex.

    {
        // Use IntelliSense to learn about possible attributes.
        // Hover to view descriptions of existing attributes.
        // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
        "version": "0.2.0",
        "configurations": [
            {
                "name": "launch Program",
                "type": "node",
                "request": "launch",
                "program": "multiclient.js" // <- added this line
            }
        ]
    }
    

    If you want to read more about debugging NodeJS apps in VS Code, see the official docs at https://code.visualstudio.com/docs/nodejs/nodejs-debugging.

    Login or Signup to reply.
  2. If the file you want to debug is the current editor, then it is simpler to use the ${file} variable in your launch configuration like so:

    {
        // Use IntelliSense to learn about possible attributes.
        // Hover to view descriptions of existing attributes.
        // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
        "version": "0.2.0",
        "configurations": [
            {
                "name": "launch Program",
                "type": "node",
                "request": "launch",
                "name": "Node: Run current file",
                "program": "${file}"
            }
        ]
    }
    

    And then look for Node: Run current file in the Launch Configurations dropdown box.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search