Beanstalk: Node.js deployment - node-gyp fails due to permission denied : <p>Deployment of a Node.js application (Node 6, npm 5) to Beanstalk fails with:</p>

<blockquote>
  <p>gyp ERR! stack Error: EACCES: permission denied, mkdir
  '/tmp/deployment/application/node_modules/heapdump/build'</p>
</blockquote>

<p>though the error is not package-specific, any node-gyp call fails.</p>

<p>The ERROR event in the AWS Console reads:</p>

<blockquote>
  <p>[Instance: i-12345] Command failed on instance. Return
  code: 1 Output:
  (TRUNCATED).../opt/elasticbeanstalk/containerfiles/ebnode.py", line
  180, in npm_install raise e subprocess.CalledProcessError: Command
  '['/opt/elasticbeanstalk/node-install/node-v6.10.0-linux-x64/bin/npm',
  '--production', 'install']' returned non-zero exit status 1. Hook
  /opt/elasticbeanstalk/hooks/appdeploy/pre/50npm.sh failed. For more
  detail, check /var/log/eb-activity.log using console or EB CLI.</p>
</blockquote>

<p>and <code>eb-activity.log</code> contained the aforementioned npm error.</p>

<p>The application was deployed manually by uploading a .zip file that did not include <code>node_modules</code>. I.e. it was not deployed via the <code>eb</code> command-line tool.</p>
