B
B
bormor2018-04-03 16:59:26
Node.js
bormor, 2018-04-03 16:59:26

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

1 answer(s)
D
Dmitry Alekseev, 2018-04-05
@Zatmil

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 question

Ask a Question

731 491 924 answers to any question