最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How do I debug a CLI with VSCode? - Stack Overflow

programmeradmin1浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论