javascript - Heroku: Node 应用程序抛出 "No default language could be detected for this app"错误

标签 javascript node.js git heroku

我正在学习 NodeJS,我正在学习的类(class)有几个项目,按部分排列。我将所有项目都放在一个主文件夹下,这也是一个 git repository .

主文件夹中的每个子文件夹本身就是一个 Node 项目,包含 package.jsonnode_modules 中的相关依赖项。问题是当我试图将一个这样的文件夹(todo-api)中的 Node 应用程序推送到 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'

这是项目的目录结构-

enter image description here

我决定将 todo-api 子文件夹单独重构到一个新项目中,这次推送到 Heroku 工作正常 -

enter image description here

我不明白为什么会出现“无默认语言”错误,尤其是当两个地方的 Node 应用程序完全相同时。有什么想法吗?

最佳答案

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

This is the command for the node buildpack .
如您所见,它需要一个 package.json 位于应用程序的根目录中,而不是子文件夹中。

这是导致构建失败的差异。您需要将您的应用放在 git 存储库的根目录下。

关于javascript - Heroku: Node 应用程序抛出 "No default language could be detected for this app"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43362014/

相关文章:

git - 将 Github 的更改 pull 到 Github

Git 比较两个分支与第三个分支的关系

javascript - Meteor 方法调用 - 等待方法完成

javascript - Javascript 中是否存在错误类型?

javascript - 抽象方法 TypeScript 的奇怪行为

javascript - 递归函数调用后循环的执行停止 - javascript

node.js - 具有版本化数据和差异端点的 REST API : optimizing bandwidth and performance

javascript - 正则表达式匹配的内容

git:如何在不更改提交 ID 的情况下以非交互方式更改已提交的提交消息?

C# 和 javascript 电子邮件验证正则表达式