我正在尝试将我的第一个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
我的猜测是Heroku不知道入口点是什么。我建议将你的backend
和frontend
应用程序分成两个独立的heroku应用程序 - 它会简化很多。但是如果你想在同一个Heroku“应用程序”中使用它们,我相信你必须在根目录中设置一个中心节点服务器,然后将/api
下的所有调用指向你的后端,以及所有其他调用你的/frontend
(或者你想要构建那个。
Here's a tutorial on Heroku that seems to walk you through what you're trying to do