Use parseArgs to Parse your Command Line

Share this video with your friends

Social Share Links

Send Tweet

From Node 18.3 and above, there is a new command line parser. Before, we would either have to use custom logic or a third-party library to explore process.argv.

I create an options object with a key of add that has an object of key type, which is a boolean, and a key of short which we pass the value of "a". Now, I pass that to parseArgs, set that to a variable, and console.log it to show you more about how parseArgs works.