Parsing Node Command Line Arguments
12:56 28 Feb 2015

I want to parse command-line arguments when my script is run with a command like:

node test.js --input=in.txt

What I am trying to do is create an optional variable for the input file. If it is not specified in the command-line, it should resolve to 'a.txt'.

I have not found an easy way of creating default parameters, or using identifiers such as --input= to not have to worry about the order in which arguments are passed (I know it does not matter in this case with one argument).

json node.js command-line-arguments