title: node.js child_process.spawn ENOENT error - only under supervisord
body: <p>I'm running a command with Node.js using child_process.spawn:</p>
  
  <pre><code>#!/usr/bin/js
  
  var spawn = require("child_process").spawn;
  
  var stockfish = spawn("stockfish");
  </code></pre>
  
  <p>This works fine using <code>$js spawntest.js</code> from the command line; it just hangs like you would expect because the subcommand is waiting for input.</p>
  
  <p>When I set this script up as a supervisord program, however, it fails:</p>
  
  <pre><code>$ sudo supervisorctl start spawntest
  spawntest: ERROR (abnormal termination)
  </code></pre>
  
  <p>Here is the contents of the stderror output log that supervisor keeps in /var/log/supervisor/spawntest-stderr---supervisor-RyULL0.log:</p>
  
  <pre><code>events.js:72
          throw er; // Unhandled 'error' event
                ^
  Error: spawn ENOENT
      at errnoException (child_process.js:980:11)
      at Process.ChildProcess._handle.onexit (child_process.js:771:34)
  
  events.js:72
          throw er; // Unhandled 'error' event
                ^
  Error: spawn ENOENT
      at errnoException (child_process.js:980:11)
      at Process.ChildProcess._handle.onexit (child_process.js:771:34)
  
  events.js:72
          throw er; // Unhandled 'error' event
                ^
  Error: spawn ENOENT
      at errnoException (child_process.js:980:11)
      at Process.ChildProcess._handle.onexit (child_process.js:771:34)
  
  events.js:72
          throw er; // Unhandled 'error' event
                ^
  Error: spawn ENOENT
      at errnoException (child_process.js:980:11)
      at Process.ChildProcess._handle.onexit (child_process.js:771:34)
  </code></pre>
  
  <p>The supervisorctl program is configured like this:</p>
  
  <pre><code>[program:spawntest]
  command=/home/gus/dev/spawntest.js
  autostart=false
  autorestart=false
  user=gus
  </code></pre>
  
  <p>Why is this failing only under Supervisor?  Are there any Node.js modules/global variables etc I can use to see what the differences are between invoking a script directly and through Supervisor?</p>