rocketeers / rocketeer

Send your projects up in the clouds
http://rocketeer.autopergamene.eu/
MIT License
2.66k stars 217 forks source link

node_modules cache #747

Open benrolfe opened 7 years ago

benrolfe commented 7 years ago

Is there a way to cache the node_modules folder? It's taking several minutes to install all the node packages on each deploy.

benrolfe commented 7 years ago

Any help @Anahkiasen?

Anahkiasen commented 7 years ago

In Rocketeer 2 there is no special mechanism in place for this (there is in Rocketeer 3 but it is not out yet). You however have several solutions at hand:

  1. Place node_modules in your shared folders so that it is reused between releases. This however makes rollbacks more difficult so it is to keep in mind
  2. Copy the node_modules from the previous release in a before hook, if it exists

Finally before doing this you can solve the issue at the package manager level – ie. look into why it is taking several minutes in the first place. Maybe give a shot at either Yarn or NPM5 which both provide faster installation times for Node dependencies. There are also some wrappers around NPM like npm-cache and stuff, older versions of NPM were notably slow so you should find things pretty easily on the web

I'd recommend to do this first because even if you can make it fast for deployments you're really just working around the problem and it will still be slow for you locally and for every first deployment on a new server, and so on.