Heroku Review App不缓存node_modules

我使用以下buildpack:heroku-buildpack-nodejs 默认情况下,它应该缓存并还原android.support.v7.widget.CardView

node_modules文件与yarn.lock一起位于应用程序的根目录。

我还将package.json添加到了"cacheDirectories": [".cache/yarn"]

在审阅应用程序构建日志分析期间,我看到:

package.json

...

-----> Restoring cache
Loading 1 from cacheDirectories (package.json):
- .cache/yarn (not cached - skipping)

...

-----> Installing dependencies
       Installing node modules (yarn.lock)

此问题似乎于2016年12月20日开放: https://github.com/heroku/heroku-buildpack-nodejs/issues/359

如何在不对每个构建都安装依赖项的情况下实现缓存机制?

katrina414 回答:Heroku Review App不缓存node_modules

  Heroku NodeJS构建包的

v83不支持使用yarn安装依赖项。这已添加到v93中。

Buildpack v93并非没有其自身的问题。由于将yarn cache path相对于$build_dir的代码硬编码为$build_dir/.cache/yarn/v2。 由于$build_dir是一个临时目录,因此不能作为下一个部署中的内容存在。

要对此进行演示,请在heroku-postbuild中为heroku-prebuild键的scripts键添加一个package.json"heroku-postbuild": "pwd" 命令脚本,以显示文件夹部署正在其中运行。

remote:        $ echo 'postbuild'; pwd
remote:        postbuild
remote:        /tmp/build_260cb9d4ad95c7671332f8a404117b59
remote:        Done in 0.10s.

构建日志的部分输出

cacheDirectories

在更高版本的buildpack中解决了纱线部署的一些问题。我建议使用当前为v165

的最新版本包

在v165版本的the cache is copied from the temporary folder中,yarn依赖项依赖于为package.json中的features键配置的依赖项

当前,此功能位于功能标志的后面。

为了启用它进行部署,请在项目中创建一个. ├── README.md ├── features ├── package.json └── yarn.lock 文件。

features

cache-native-yarn-cache=true 文件中写

remote:
remote: -----> Restoring cache
remote:        Loading 1 from cacheDirectories (package.json):
remote:        - .cache/yarn

重新运行您的部署应产生类似于以下内容的日志:

{{1}}
本文链接:https://www.f2er.com/3117005.html

大家都在问