Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Avoid npm refresh after every deployment on Heroku

I have a Node.js website hosted on Heroku, that I deploy with git. I use several node modules, referenced in package.json; is there a way to prevent Heroku to 'refresh' them each time I deploy a new version of the code, as long as package.json did not change?

Note: this would be especially useful for 'native' modules, whose compilation takes a bit of time; for .js-only modules, I was successful removing them from package.json, and adding their node_modules/ folder in the git repo.

like image 521
etienne Avatar asked May 22 '12 08:05

etienne


2 Answers

I'm the maintainer of the official Heroku Node.js Buildpack.

We have a new version of the buildpack in beta that features caching support, designed specifically for the use case you described above. You can read more about it at https://github.com/heroku/heroku-buildpack-nodejs/tree/diet#about-this-refactor

Eventually this will become the default Node.js buildpack on Heroku, but if you want to use it now you'll need to set the BUILPACK_URL config var explicitly:

heroku config:set BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-nodejs#diet -a my-node-app
git commit -am "fakeout" --allow-empty
git push heroku
like image 188
Zeke Avatar answered Oct 23 '22 07:10

Zeke


Seems like there has recently been progress by David Dollar at the heroku-buildpack-nodejs.

In short:

heroku config:set BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-nodejs

See answer here: https://stackoverflow.com/a/18535675/1318839

like image 41
Poindexter Avatar answered Oct 23 '22 07:10

Poindexter