问题描述
我有一个Rails应用程序,使用React,Webpack和Yarn作为客户端。我在/ client目录中拥有与客户端相关的所有内容。这包括我的yarn.lock和package.json文件。我有一个Procfile,它可以在/ client中执行cds并正确运行 yarn run build
。这在本地工作,没有错误。但是,当我部署/推送到Heroku时,我的推送被拒绝,并且出现以下错误:
远程:cd client& amp ;&安培;纱线运行构建:生产
远程:sh:1:纱线:未找到
远程:耙中止!
remote:命令失败,状态为(127):[cd client&&生产线:生产...]
这对我说的是Heroku不能在根级找到yarn.lock文件。如何让Heroku在my / client目录下使用 yarn.lock
文件?
或者是原因这个错误的其他东西完全是什么?
刚刚通过类似的事情我自己。您需要订购构建包,以便节点处于第一位。如果一个yarn.lock在你的根目录下(或者你的引擎键在@ remydib的答案中),那么节点buildpack将安装纱线,然后安装你的包。如果你在/ client中有一个 yarn.lock
,把它放在根目录下,然后在它上面添加一个 postinstall
脚本,说 cd client&&在我的情况下(rake资产:预编译调用纱线并失败),出于某种原因,当buildpacks进入ruby时 - >
希望这有助于您。
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.lock and package.json files. I have a Procfile that cds into /client and properly runs yarn run build
. This works locally with no errors. However, when I deploy/push to Heroku, my push is rejected and I get the following error:
remote: cd client && yarn run build:production
remote: sh: 1: yarn: not found
remote: rake aborted!
remote: Command failed with status (127): [cd client && yarn run build:production...]
What this says to me is that Heroku wasn't able to find a yarn.lock file in the root level. How do I get Heroku to use the yarn.lock
file within my /client directory?
Or is the cause of this error something else entirely?
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.
这篇关于如何让Heroku识别一个子目录(不是root)中的yarn.lock或package.json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!