title: Parsing Node Command Line Arguments
body: <p>I am learning how to use node.js, but am having trouble parsing command-line arguments. The following line:</p>
  
  <pre><code>node test.js --input=in.txt
  </code></pre>
  
  <p>Gives a parsing error when the code reaches this command:</p>
  
  <pre><code>var fileName = JSONparse.(process.argv[2]);
  </code></pre>
  
  <p>Results in the error:</p>
  
  <pre><code> undefined
  --input=in.txt 
  
  Syntax error: Unexpected number
  </code></pre>
  
  <p>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'.</p>
  
  <p>I have not found an easy way of creating default parameters, or use 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).</p>