title: Installing npm canvas on elasticbeanstalk - npm install error
body: <p>I am trying to deploy a node.js server running on EC2 via Elasticbeanstalk.
  The problem I am having is during the rebuild of the canvas npm module.
  The command 'canvas@1.1.6 install: <code>node-gyp rebuild</code>' fails as follows:</p>
  
  <pre><code>&gt; canvas@1.1.6 install /tmp/deployment/application/node_modules/canvas
  &gt; node-gyp rebuild
  
  gyp ERR! clean error 
  gyp ERR! stack Error: EACCES, unlink 'build'
  gyp ERR! System Linux 3.10.35-43.137.amzn1.x86_64
  gyp ERR! command "node" "/opt/elasticbeanstalk/node-install/node-v0.10.26-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
  gyp ERR! cwd /tmp/deployment/application/node_modules/canvas
  gyp ERR! node -v v0.10.26
  gyp ERR! node-gyp -v v0.12.2
  gyp ERR! not ok 
  
  npm ERR! canvas@1.1.6 install: `node-gyp rebuild`
  npm ERR! Exit status 1
  npm ERR! 
  npm ERR! Failed at the canvas@1.1.6 install script.
  npm ERR! This is most likely a problem with the canvas package,
  npm ERR! not with npm itself.
  npm ERR! Tell the author that this fails on your system:
  npm ERR!     node-gyp rebuild
  npm ERR! You can get their info via:
  npm ERR!     npm owner ls canvas
  npm ERR! There is likely additional logging output above.
  </code></pre>
  
  <p>The problem appears to be that the <code>npm install canvas</code> command is not being run with appropriate privileges. If I manually ssh into the server and run 'sudo npm install canvas', everything works fine. This tells me that all the appropriate dependencies are installed fine (I followed these instructions: <a href="https://github.com/Automattic/node-canvas/wiki/Installation---Amazon-Linux-AMI-(EC2)" rel="nofollow">https://github.com/Automattic/node-canvas/wiki/Installation---Amazon-Linux-AMI-(EC2)</a>). It's just the elasticbeanstalk deployment which is causing the grief.</p>
  
  <p>I attempted to enable root access during deployment by adding commands to a .config file inside .ebextensions as follows:</p>
  
  <pre><code>option_settings:
    - namespace: aws:elasticbeanstalk:container:nodejs:staticfiles
      option_name: /public
      value: /public
    - option_name: NODE_ENV
      value: production
  
  commands:
    01_enable_rootaccess:
      command: echo Defaults:root \!requiretty &gt;&gt; /etc/sudoers
    02_no-cert:
      command: sudo /opt/elasticbeanstalk/node-install/node-v0.10.10-linux-x64/bin/npm config set ca ""
  </code></pre>
  
  <p>but it doesn't appear to make any difference.</p>
  
  <p>What am I doing wrong, and how can I get canvas to install nicely during eb deployment?</p>