title: NodeJS Child Process EXEC Command Failed with NVM Permission denied OSX
body: <p>I am attempting to launch nvm within a child process in Nodejs on OSX
  However in doing so, I am getting the following error:
  /bin/sh: /Users/miker/.nvm/nvm.sh: Permission denied. child process exited with code 126 (I call the explicit path to nvm, since running without it, the child process can't see the executable.)</p>
  
  <p>This is obvious that it is a permission issue. However, I am not sure why since I can launch the commands on there own without issue. It is only when launching in a child process does this fail. Perhaps, the child process runs in the context of another profile? If so, is there a way to maintain the current profile or context?</p>
  
  <p>Here is an example code</p>
  
  <pre><code>let exec = require('child_process').exec;
  
  let child = exec('echo $NVM_DIR &amp;&amp; $NVM_DIR/nvm.sh use &amp;&amp; npm install', {
      cwd: './build/'
  });
  
  child.stdout.on('data',
      (data) =&gt; {
          console.log(data);
      });
  
  child.stderr.on('data',
     (data) =&gt; {
          //throw errors
          console.log(data);
      });
  
  child.on('close', (code) =&gt; {
      console.log('child process exited with code ' + code);
  });
  </code></pre>
  
  <p>I am using NodeJS 7.2.1 and nvm 0.32.1
  If anyone has a solution to this problem, please let me know.</p>