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?
1 Answer
Reset to default 7In 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.