安装依赖项后如何清理 heroku 中的缓存?

How to clean cache in heroku after installing dependencies?

主题:Heroku 问题:在 heroku 中安装我的 node js 应用程序后,我在 package.json 中做了一些更改。现在,当我再次尝试推送更改时,没有安装新的依赖项。 Heroku 正在从缓存中选择依赖项。

如何在 heroku 中禁用缓存?

感谢大家的回复。

经过大量谷歌搜索并花时间解决我的问题后,我终于解决了我的问题。 我认为如果有人面临类似的困境,post 一个答案会更好。

下面是我找到答案的文档https://devcenter.heroku.com/articles/nodejs-support

  1. 默认情况下,在 heroku production 中设置为 true。这就是为什么只安装依赖项的原因。 ( & 跳过 devDependencies )

    heroku config:set NPM_CONFIG_PRODUCTION=false
    

将 production 设置为 false,以强制 heroku 安装所有包。

** Only do this if doing development.
  1. Heroku默认缓存所有的依赖,部署更快

    heroku config:set NODE_MODULES_CACHE=false
    
    $ git commit -am 'disable node_modules cache' --allow-empty
    
    $ git push heroku master
    
    ** Preferable only if new dependencies are added in package.json
    

我知道现在回答这个问题已经太晚了,但难怪有人需要随时解决这个问题...

无论如何,您可以通过安装 heroku-builds 插件轻松清除应用程序的构建缓存。

  1. 安装:

heroku plugins:install heroku-builds

  1. 用法:

heroku builds:cache:purge -a your-app-name

注: 缓存将在下一次部署时重建。如果您没有任何新代码要部署,您可以推送一个空提交。

$ git commit --allow-empty -m "Purge cache"

$ git push heroku master