问题描述
我正在使用我的github存储库连接到heroku,但是当我单击deploy分支时,出现以下错误:
! No default language Could be detected for this app.
HINT: This occurs when Heroku cannot detect the buildpack to use for this application
automatically.
See https://devcenter.heroku.com/articles/buildpacks
! Push Failed
我认为这是因为我的项目有2个文件夹(前端和后端),并且每个文件夹都有自己的package.json文件。经过研究,似乎heroku在根文件夹中需要packages.json。我可以在根目录中创建一个新的packages.json文件吗?我需要通过github进行部署。
我可以只将package.json从后端复制粘贴到根目录吗?
解决方法
可以将前端和后端部署到单个heroku实例,但是很困难。最好单独部署它们。
话虽如此,导致问题的原因确实是根目录中缺少package.json。如果您使用的是免费套餐,则在部署后仅会打开1个端口,因此您必须对此有所创造。如果您坚持将两个应用程序都放在一个应用程序上,则以下内容可能有用。 Deploy the backend and frontend on the same Heroku app/dyno