在 Heroku 上每次部署后避免 npm refresh [英] Avoid npm refresh after every deployment on Heroku
问题描述
我在 Heroku 上托管了一个 Node.js 网站,我使用 git 部署了该网站.我使用了几个 node 模块,在 package.json 中引用;有没有办法防止 Heroku 在每次部署新版本的代码时刷新"它们,只要 package.json 没有改变?
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?
注意:这对于编译需要一些时间的原生"模块特别有用;对于 .js-only 模块,我成功地从 package.json 中删除了它们,并在 git repo 中添加了它们的 node_modules/文件夹.
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.
推荐答案
我是官方 Heroku Node.js Buildpack 的维护者.
I'm the maintainer of the official Heroku Node.js Buildpack.
我们有一个新版本的 buildpack 测试版,它具有缓存支持,专为您上面描述的用例而设计.您可以在 https://github 上阅读更多相关信息.com/heroku/heroku-buildpack-nodejs/tree/diet#about-this-refactor
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
最终这将成为 Heroku 上默认的 Node.js buildpack,但如果您现在想使用它,您需要明确设置 BUILPACK_URL 配置变量:
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
这篇关于在 Heroku 上每次部署后避免 npm refresh的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!