How to Debug Node.Js Applications

How do I debug Node.js applications?

The V8 debugger released as part of the Google Chrome Developer Tools can be used to debug Node.js scripts. A detailed explanation of how this works can be found in the Node.js GitHub wiki.

How to debug node.js application with Visual Studio 2013 and Node Tools NTVS

For everyone who asks receives, and the one who searches finds....

(and yes, I did spend a long time searching and trying before posting here..)

Settings

Kind of nice to debug node.js server with VS..

hope this helps someone

Edit: The arguments to node.exe can be hard to read in the image. It must be

 --debug=<portno>

that is with two dashes (and not just one) to specify the debug port.

How do I debug Node.js applications?

The V8 debugger released as part of the Google Chrome Developer Tools can be used to debug Node.js scripts. A detailed explanation of how this works can be found in the Node.js GitHub wiki.

How Run-Script works in VS Code for node.js applications when debugging?

Here are the steps to solve your mystery: by following along, you'll both discover the task configuration settings for the elusive option, and discover how it was added to your list:

  1. Create an empty folder (I named mine so-70196209 after this question ID), and open it in a new VS Code workspace.

  2. Create a package.json file in the folder. Make sure it has a start:debug script entry like this:

    package.json:

    {
    "name": "so-70196209",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "scripts": {
    "start:debug": "echo \"Success\"",
    "test": "echo \"Error: no test specified\" && exit 1"
    },
    "author": "",
    "license": "MIT"
    }
  3. In the VS Code menu, select "Run" > "Add Configuration..."

    run > add configuration

  4. In the list that appears, select "Node.js":

    node.js

    A file at .vscode/launch.json will be created with a default task like this:

    .vscode/launch.json:

    {
    // 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": [
    {
    "type": "pwa-node",
    "request": "launch",
    "name": "Launch Program",
    "skipFiles": [
    "<node_internals>/**"
    ],
    "program": "${file}"
    }
    ]
    }

    You can delete this default task later if you don't want to keep it, but just leave it for now and follow along to the end.

  5. Select the "Run and Debug" icon in the Activity Bar.

  6. In the "Run and Debug" Side Bar, select the dropdown menu and choose "Node.js...":

    node.js

  7. In the list that appears, find the entry with the text "Run Script: start:debug". Find the gear icon on the right, and select the gear.

    If you hover over the gear, a tooltip will appear with the text "Edit Debug Configuration in launch.json"

    run script: start:debug

    This will add a new entry to .vscode/launch.json, and this entry is the one that you've been searching for. (The reason why it wasn't in your launch config, but was in your dropdown list, is because you previously clicked the entry line at some point, but not the gear. I don't know why this adds it to the dropdown and not the config, but that's how it works right now.)

    The config file now looks like this:

    .vscode/launch.json:

    {
    "version": "0.2.0",
    "configurations": [
    {
    "type": "pwa-node",
    "request": "launch",
    "name": "Launch Program",
    "skipFiles": [
    "<node_internals>/**"
    ],
    "program": "${file}"
    },
    {
    "type": "node-terminal",
    "name": "Run Script: start:debug",
    "request": "launch",
    "command": "npm run start:debug",
    "cwd": "${workspaceFolder}"
    }
    ]
    }

    The "Run and Debug" dropdown menu now has the entry you want:

    run and debug dropdown menu

Problem solved! /p>


Related Topics



Leave a reply



Submit