避免在Heroku上进行每次部署后的npm刷新 [英] Avoid npm refresh after every deployment on Heroku

查看:92
本文介绍了避免在Heroku上进行每次部署后的npm刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在Heroku上托管的Node.js网站,我使用git进行部署。
我使用几个节点模块,在package.json中引用;有没有一种方法可以防止Heroku每次部署新版本的代码时刷新它们,只要package.json没有改变?



注意:这对于编译需要一些时间的本地模块特别有用;对于.js-only模块,我成功地将它们从package.json中删除,并将它们的node_modules /文件夹添加到了git repo中。

我是官方Heroku Node.js Buildpack的维护者。



我们有一个beta版的buildpack新版本,它具有缓存支持功能,专为你上面描述的用例。您可以在 https:// github上阅读更多内容。 com / heroku / heroku-buildpack-nodejs / tree / diet#关于此重构



最终,这将成为Heroku上的默认Node.js构建包,但是如果你想现在使用它,你需要显式地设置BUILPACK_URL config var:

  heroku config:set BUILDPACK_URL = https://github.com/heroku/heroku-buildpack-nodejs#diet -a my-node-app 
git commit -amfakeout--allow-empty
git push 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.

解决方案

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

这篇关于避免在Heroku上进行每次部署后的npm刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆