I have a Rails application using React, Webpack, and Yarn for the client side. I have everything relating to the client side within the /client directory. This includes my yarn.
Just been through a similar thing myself. You need to order the buildpacks so that node is first. If a yarn.lock is in your root dir (or yarn is in your "engines" key as in @remydib's answer), then the node buildpack will install yarn and then your packages. If you have a yarn.lock
in /client, put one in root, and add a postinstall
script to it that says cd client && yarn run build
.
In my case (rake assets:precompile calls yarn and fails), for some reason when the buildpacks go ruby -> node, Heroku doesn't wait for node to install before trying to run rake tasks, and we go kablooie.
Hope this helps.