Skip to content

Test launch option that allows run node project by npm script #12253

Closed
@weinand

Description

@weinand

Test for #2726:

Complexity 2

A frequent feature request was to support running 'npm' scripts directly from a launch configuration.
This has now become possible by the following small tweaks of existing launch configuration concepts:

  • Any program available on the PATH (e.g. 'npm', 'mocha', 'gulp', etc.) can now be used for the runtimeExecutable attribute and arguments can be passed via the runtimeArgs.
  • The program attribute is no longer mandatory which helps if the npm script already specifies the program to launch.
  • If you specify a debug port via the port attribute, the --debug-brk=nnnn attribute will no longer be automatically added because the debug port is typically specified by the npm scripts as well.

So if your package.json has a 'debug' script, e.g.:

  "scripts": {
    "debug": "node --nolazy --debug-brk=5858 myProgram.js"
  },

the corresponding launch config could look like this:

{
    "name": "Launch via NPM",
    "type": "node",
    "request": "launch",
    "cwd": "${workspaceRoot}",
    "runtimeExecutable": "npm",
    "runtimeArgs": [
        "run-script", "debug"
    ],
    "port": 5858
}

Verify that you can start a debug session by using your favourite tool/scripts in a 'node' launch config.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions