简体   繁体   English

如何将子目录中的 create-react-app 部署到 Heroku

[英]How to deploy create-react-app in subdirectory to Heroku

I have the following setup in my github repo (NOTE: my package.json is in /dashboard subfolder. Problem?).我的 github 存储库中有以下设置(注意:我的package.json位于/dashboard子文件夹中。有问题吗?)。 My problem is that i cannot deploy a create-react-app thats in a subdirectory with Heroku (This error happens upon deployment -> " App not compatible with buildpack: https://github.com/mars/create-react-app-buildpack.git ").我的问题是我无法在 Heroku 的子目录中部署 create-react-app (此错误在部署时发生->“ App not compatible with buildpack: https://github.com/mars/create-react-app-buildpack.git ")。 Is there a way to move /dashboard to the root of the repo?有没有办法将/dashboard移动到 repo 的根目录? Or can i use another hosting service (Netlify)?或者我可以使用其他托管服务(Netlify)吗? I have tried other solutions such as using config vars in Heroku settings, but still doesnt work.我尝试了其他解决方案,例如在 Heroku 设置中使用配置变量,但仍然不起作用。 Step by step process would be appreciated.一步一步的过程将不胜感激。

在此处输入图像描述

在此处输入图像描述

Answer : for anyone who comes across in future, the simplest way by far is to instead use Netlify -- Log in, then drag your root folder into drag and drop area under "Sites", then under Settings -> Build & Deploy -> Continuous Deployment -> Build settings (connect Netlify to Github repo first) youll enter the subdirectory name into Base Directory field (no slashes), then CI= npm run build for Build Command, and finally yourSubdirectoryName/build for Publish Directory field.回答:对于将来遇到的任何人,到目前为止最简单的方法是改用 Netlify -- 登录,然后将您的根文件夹拖到“站点”下的拖放区域,然后在 Settings -> Build & Deploy ->持续部署 -> 构建设置(首先将 Netlify 连接到 Github 存储库)您将在基本目录字段中输入子目录名称(无斜杠),然后CI= npm run build构建命令,最后是发布目录字段的子目录名称yourSubdirectoryName/build Save and then trigger another deployment.保存然后触发另一个部署。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM