title: Node JS - child_process spawn('npm install') in Grunt task results in ENOENT error
body: <p>I'm having some difficulty with a Grunt task I'm authoring.  I'm trying to execute npm install, followed by bower install, followed by a grunt hub target (to trigger a build command for multiple sub-projects).</p>
  
  <p>The problem I'm encountering lies with child_process.  I get spawn ENOENT error if I run the following commands in my grunt task, with the npm install spawn command that's currently commented out:</p>
  
  <pre><code>    var path = require('path'),
          projectPath = path.resolve(process.cwd(), this.data.activity );
  
          grunt.log.debug('project path computed as: ', projectPath);
          process.chdir( projectPath );
  
          console.log('current dir is: ', process.cwd());
          console.log('EVN is: ', process.env);
  
          var spawnProcess = spawn('ls');
          // var spawnProcess = spawn('npm install');
  
          spawnProcess.stdout.on('data', function (data) {
              console.log('' + data);
          });
  
          spawnProcess.stderr.on('data', function(data) {
  
              console.log('something went wrong installing deps for ' + path + '.  Error: ', data);
          });
  
          spawnProcess.on('close', function (exitCode) {
  
              console.log( 'ls has finished with Exit Code: ' + exitCode);
          });
  </code></pre>
  
  <p>the current code (with ls instead of npm install) results in:</p>
  
  <pre><code>   running "install:projects" (install) task[D] Task source: /Users/zedd45/proj/Gruntfile.js
  Verifying property install.projects exists in config...OK
  File: [no files]
  [D] project path computed as:  /Users/zedd45/proj/activity/web/client
  current dir is:  /Users/zedd45/proj/activity/web/client
  EVN (abbreviated) is:  { 
     TERM_PROGRAM: 'iTerm.app',
     SHELL: '/bin/bash',
     PWD: '/Users/zedd45/proj',
   ...
    OLDPWD: '/Users/zedd45/proj/activity/web/client',
    _: '/usr/local/bin/grunt' }
  
  GruntFile.js
  bower.json
  package.json
  this_is_the_directory_you_are_looking_for.txt
  ls has finished with Exit Code: 0
  </code></pre>
  
  <p>but if I change 'ls' to 'npm install' I get instead 
  ``Fatal error: spawn ENOENT</p>
  
  <p>immediately following the ENV print.</p>
  
  <p>I have tried chmod 777 for that directory, which doesn't seem to help.</p>
  
  <p>I have also tried: </p>
  
  <pre><code>// var spawnProcess = spawn('npm install', {'cwd': projectPath});
  </code></pre>
  
  <p>and </p>
  
  <pre><code>// var spawnProcess = spawn('npm install', [], {'cwd': projectPath});
  </code></pre>
  
  <p>The former results in </p>
  
  <blockquote>
    <p>Warning: Object # has no method 'slice' Use --force to
    continue.</p>
  </blockquote>
  
  <p>the later still results in the ENOENT error.</p>
  
  <p>Any help with exactly what this ENOENT error is would probably help a great deal; I haven't had much success with Googling it nor with the <a href="http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options">child process API docs</a></p>