title: avoid rebuilding node_modules in elastic beanstalk
body: <p>We have a fairly simple node.js app, but due to AWS Elastic Beanstalk deployment mechanism, it takes about 5 minutes to roll-out a new version (via <code>git aws.push</code>) even after a single file commit.</p>
  
  <p>I.e. the commit itself (and upload) is fast (only 1 file to push), but then Elastic Beanstalk fetches whole package from S3, unzips it and runs <code>npm install</code>, which causes node-gyp to compile some modules. Upon installation/building completion, Elastic Beanstalk wipes <code>/var/app/current</code> and replaces it with the new app version.</p>
  
  <p>Needless to say, constant node_modules rebuilding is not necessary, and rebuilding that takes 30 seconds on my old Macbook Air, takes >5 mins on a ec2.micro instance, not fun.</p>
  
  <p>I see two approaches here:</p>
  
  <ol>
  <li>tweak <code>/opt/containerfiles/ebnode.py</code> and play with node_modules location to avoid its removal and rebuilding upon deployment. </li>
  <li>set up a git repo on Elastic Beanstalk EC2 instance and basically re-write deployment procedure ourselves, so /var/app/current receives pushes and runs <code>npm install</code> only when necessary (which makes Elastic Beanstalk to look like OpsWorks..)</li>
  </ol>
  
  <p>Both options lack grace and are prone to issues when Amazon updates their Elastic Beanstalk hooks and architecture.</p>
  
  <p>Maybe somebody has a better idea how to avoid constant rebuilding of node_modules that are already present in the app dir? Thank you.</p>