温馨提示:本文翻译自stackoverflow.com,查看原文请点击:javascript - Heroku: "No default language could be detected for this app" error thrown for node app
git heroku javascript node.js

javascript - Heroku:节点应用程序抛出“此应用程序未检测到默认语言”错误

发布于 2020-08-06 17:15:00

我正在学习NodeJS,我要学习的课程有按项目分类的几个项目。我将所有项目都放在一个主文件夹下,该主文件夹也是git仓库

主文件夹中的这些子文件夹中的每个子文件夹本身都是一个节点项目,带有中的package.json相关子项及其相关性node_modules问题是当我尝试将其中一个文件夹(todo-api)中的节点应用程序推送到heroku时,出现以下错误-

remote: Compressing source files... done.
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...
remote: 
remote: !       Push rejected to agile-forest-32749.
remote: 
To https://git.heroku.com/agile-forest-32749.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/agile-forest-32749.git'

这是项目的目录结构-

在此处输入图片说明

我决定将todo-api子文件夹全部重构为一个新项目,这一次向Heroku的推送就可以了-

在此处输入图片说明

我不明白为什么会收到“无默认语言”错误,尤其是当节点应用在两个地方都完全相同时。有什么想法吗?

查看更多

提问者
Manish Giri
被浏览
2
Damien MATHIEU 2017-04-12 15:41

Heroku有一组默认的buildpacks,在需要检测您的应用程序语言时使用。
为了进行检测,它将运行bin/detect每个默认buildpack 命令,直到其中一个返回0退出代码为止。

这是节点buildpack的命令
如您所见,它要求a package.json必须位于应用程序的根目录中,而不是子文件夹中。

这是导致构建失败的区别。您需要将应用程序放置在git存储库的根目录下。