我正在学习 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 发布,翻译遵循 CC BY-SA 4.0 许可协议
Heroku 有一组默认的 buildpacks,当它需要检测你的应用程序的语言时使用。
为了进行检测,它运行每个默认构建包的
bin/detect
命令,直到其中一个返回 0 退出代码。这是节点 buildpack 的命令。
如您所见,它需要一个
package.json
位于应用程序的根目录中,而不是子文件夹中。这是导致构建失败的差异。您需要将您的应用程序放在 git 存储库的根目录下。