Heroku github 推送失败,无法检测默认语言

Heroku github push failed, cannot detect default language

我正在使用我的 github 存储库连接到 heroku,但是当我单击部署分支时,出现以下错误:

 !      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 个文件夹(前端和后端),每个文件夹都有自己的 packages.json 文件。经过研究,heroku 似乎需要根文件夹中的 packages.json。我可以在根目录中创建一个新的 packages.json 文件吗?我需要通过 github.

进行部署

我可以只从后端复制粘贴 packages.json 到根目录吗?

将前端和后端部署到单个 heroku 实例是可能的,但很困难。最好分开部署。

话虽如此,您的问题确实是根目录中缺少 package.json。如果您使用的是免费套餐,则部署后只会打开 1 个端口,因此您必须在这方面发挥创意。如果您坚持要在一个应用程序上同时获得这两个功能,则以下内容可能会有用。 Deploy the backend and frontend on the same Heroku app/dyno