nodejs-custom-version-openshift icon indicating copy to clipboard operation
nodejs-custom-version-openshift copied to clipboard

Caching node_modules?

Open jeremy303 opened this issue 10 years ago • 3 comments

I'm looking for a solution for caching my node and bower dependencies rather than have them fetched at every build, which takes forever. (I know for production they should be in the git repo, but this happens to be a development system that for the moment at least is being pushed very frequently.)

Suggestions? Thanks!

jeremy303 avatar Jan 28 '16 15:01 jeremy303

@HolySamosa you could try this approach to set amount of seconds before fetching from server

$ cd $HOME
$ echo 'cache-min = 9999999' >> .npmrc

But I would recommend changing those ninths to something lesser so your deps would update, let's say, once a week.

ihorskyi avatar Jan 28 '16 16:01 ihorskyi

@HolySamosa in general for nodejs/npm, npm caches the packages in ~/.npm and you control the expiry by setting npm config set cache-min <val> as @igor-galchevsky mentioned. Or use something like npm install --no-registry or npm install --cache-min <val>.

The other alternative I can think off would be to run like a proxy cache service: https://www.npmjs.com/package/npm-proxy-cache.

Now as re: specifically to OpenShift, it should cache the npm dependencies (don't think it handles bower) - well, use the cache unless you have a force_clean_build marker set. What does sshing into your app and running cd app-root/repo && npm install do? Does it pull down dependencies every single time?

Aah, I can see where this happen - if you using the Jenkins pieces to do the build - that the case? That just might be starting up a new builder instance every single time, so there is no cache to reuse - its a brand new machine/instance/gear/container/. You might want to configure Jenkins with a persistent slave - that way the cache/packages remain for every subsequent build.

HTH

ramr avatar Jan 28 '16 22:01 ramr

Closing this issue out.

ramr avatar Apr 06 '16 07:04 ramr