admin管理员组

文章数量:1319022

I have a simple CLI written with Node.js. I want to debug that CLI with VSCode's built in debugging system but, I don't know how to attach the necessary mands to the debugger, whether it be parameters in the package.json or the launch.json, or both.

Let's say the CLI functions has the following mand syntax:

> my_cool_cli <mand>

In application, I'd do this:

> my_cool_cli start

And it would print:

Hello world!

Assume that the CLI is built using the mander library. It has been linked with npm, installed, it's globally accessible, and I can run it with no issues (other than all the unseen bugs) from the standard terminal.

I find that when I enter my_cool_cli start, it does not return 'Hello world!' as it should, because there is a bug. How can I debug this CLI with VSCode?

I have a simple CLI written with Node.js. I want to debug that CLI with VSCode's built in debugging system but, I don't know how to attach the necessary mands to the debugger, whether it be parameters in the package.json or the launch.json, or both.

Let's say the CLI functions has the following mand syntax:

> my_cool_cli <mand>

In application, I'd do this:

> my_cool_cli start

And it would print:

Hello world!

Assume that the CLI is built using the mander library. It has been linked with npm, installed, it's globally accessible, and I can run it with no issues (other than all the unseen bugs) from the standard terminal.

I find that when I enter my_cool_cli start, it does not return 'Hello world!' as it should, because there is a bug. How can I debug this CLI with VSCode?

Share Improve this question edited Jun 17, 2018 at 18:49 glotchimo asked Jun 17, 2018 at 18:23 glotchimoglotchimo 6851 gold badge5 silver badges24 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

In order to debug with the console mands, the mands have to be passed as arguments in launch.json within the given launch configuration.

{
    "type": "node",
    "request": "launch",
    "name": "Launch My Cool CLI",
    "program": "${workspaceFolder}//index.js",
    "args": [
        "start"
    ]
}

There is no need to provide the application name my_cool_cli in the arguments.

本文标签: javascriptHow do I debug a CLI with VSCodeStack Overflow