Answer the question
In order to leave comments, you need to log in
Debugging NodeJS in VSCode - how to add a breakpoint for console utility?
I am writing a console utility
How to create a breakpoint so that it works when the utility is launched with parameters
(ie node app --flag1 --flag2).
The default debugging mode works as if the parameters were not specified
(i.e. running the program on node app)
Answer the question
In order to leave comments, you need to log in
https://www.npmjs.com/package/command-line-args
index.js
const commandLineArgs = require('command-line-args');
const optionDefinitions = [
{ name: 'flag1', type: Boolean },
{ name: 'flag2', type: Boolean }
];
const options = commandLineArgs(optionDefinitions);
...
if(options.flag1) {
debugger
}
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question