title: Node - check existence of command in path
body: <p>I have a unique problem where I need to use Node to iterate over several Unix-style commands and see if they exist in the <code>path</code> of a Windows installation.</p>
  
  <p>For instance, Windows doesn't support <code>ls</code> natively. However, supposing someone installed <code>git</code> and checked to include Unix commands, it would.</p>
  
  <p>I need to know whether or not <code>ls</code> and other commands are in the system <code>path</code>.</p>
  
  <p>Right now, I'm using <code>child_process</code> to run <code>help</code> on each command. I then check the response of running it. This is messy and dangerous. I don't want to run 30 arbitrary commands from Node:</p>
  
  <pre><code>var spawnSync = require('child_process').spawnSync;
  var out = spawnSync('ls', ['/?'], {encoding: 'utf8'});
  </code></pre>
  
  <p>How else can I check for the existence of these commands?</p>