How to get Heroku to recognize a yarn.lock or package.json within a subdirectory (not root)

后端 未结 6 2239
终归单人心
终归单人心 2021-02-19 10:11

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.

6条回答
  •  闹比i
    闹比i (楼主)
    2021-02-19 11:05

    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.

提交回复
热议问题