This originally appeared on coderwall.
Today I ran into an issue with Heroku and the way its official buildpack for Node caches node_modules
. Namely, I was forced to fork a couple of modules so I updated package.json
to point to GitHub repositories (see this tip).
Unfortunately, Heroku stubbornly refused to modules from the updated path and actually npm
wasn’t behaving much better on my local machine either but there at least I could manually delete the node_modules
and re-install everything. Committing and pushing minor updates to package.json
didn’t help so I finally looked into buildpack’s code
It turns out that it always runs npm prune
on cached modules so I decided to leverage that. So to clear the modules cache:
- I removed all the modules from the
package.json
- Committed and pushed that change to Heroku
- Waited for the buildpack to prune the cache
- Returned all the modules to
package.json
- Committed and pushed again to Heroku
After that Heroku correctly downloaded my forked modules.
Last modified on 2014-03-08