When a user is using
yarn to perform build tasks, it may appear that
yarn is reinstalling node modules even though the build is expected to be using the Heroku cache.
true. If it is, the build is using the Heroku build cache. This is cached from build to build to be reused.
If it is
false or blank, set it to true:
heroku config:set NODE_MODULES_CACHE=true -a APP_NAME
true, the buildpack will copy the node modules from the app directory (
$build_directory/node_modules) to the Heroku cache at the end of the build. On the next build, the buildpack will restore those node modules to the app directory, then it will run
yarn install and use the
yarn.lock to resolve dependencies.
If there are multiple node_modules directories (for example, a directory for
server and a directory for
ui), the app will need to use
cacheDirectories to customize for multiple node modules cache directories. There's more information here: https://devcenter.heroku.com/articles/nodejs-support#custom-caching