title: Nodejs command line app: unexpected token `else'
body: <p>I'm trying to create a node command line app.
  What I am doing is extracting emails from a document full of information.</p>
  
  <p>But when I have run the command <code>npm link</code> to make the script globally available, I get these errors:</p>
  
  <pre><code>/c/Users/petfle/AppData/Roaming/npm/email-extract: line 11: syntax error near unexpected token `else'
  /c/Users/petfle/AppData/Roaming/npm/email-extract: line 11: `else '
  </code></pre>
  
  <p>My code passed linting, and I can't see any erros. I'm new to node, so it might be something simple, node specific thing that I don't see.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>#!/c/Program\ Files/nodejs/node
  
  var file_stream = require('fs');
  
  var source = process.argv[2];
  var output = process.argv[3];
  
  file_stream.readFile(source, 'utf8', function (error, data) {
      var list_of_emails = extract_emails(data);
      write_to_file(list_of_emails);
  });
  
  function extract_emails(data) {
      return data.match(/([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)/g);
  }
  
  function write_to_file(emails) {
      file_stream.writeFile(output, emails.join('\n'), 'utf8', function (error) {
          console.log('Wrote ' + emails.length + ' lines to ' + output);
      });
  }
  </code></pre>
  
  <p>EDIT: 
  It works if I remove the shebang and run it with <code>node myscript.js file.txt file2.txt</code>. I'm on windows.</p>
  
  <p>EDIT 2:
  I'm runing this in the Git Bash. Even on windows it did run a simpler script fine with the shebang.</p>