Node + React部署到Heroku:此应用程序无法检测到默认语言

问题描述 投票:0回答:1

我正在尝试将我的第一个Node + React(+ MongoDB到Mongoose)应用程序部署到Heroku,但是当运行命令git push heroku master时,我收到此错误:

remote: Building source:
remote:
remote:  !     No default language could be detected for this app.
remote:             HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.
remote:             See https://devcenter.heroku.com/articles/buildpacks
remote:
remote:  !     Push failed
remote: Verifying deploy...

该错误表明Heroku无法识别我的应用程序的语言。我想这与我的项目结构有关,看起来我很遗憾需要重新组织它:

/root
  /backend
    - models
    - node_modules
    - ...
    - package-lock.json
    - package.json
  /frontend
    - node_modules
    - public
    - redux
    - ...
    - package-lock.json
    - package.json
node.js mongodb reactjs heroku
1个回答
0
投票

我的猜测是Heroku不知道入口点是什么。我建议将你的backendfrontend应用程序分成两个独立的heroku应用程序 - 它会简化很多。但是如果你想在同一个Heroku“应用程序”中使用它们,我相信你必须在根目录中设置一个中心节点服务器,然后将/api下的所有调用指向你的后端,以及所有其他调用你的/frontend(或者你想要构建那个。

Here's a tutorial on Heroku that seems to walk you through what you're trying to do

© www.soinside.com 2019 - 2024. All rights reserved.