Heroku:“无法检测到此应用程序的默认语言";为节点应用程序抛出的错误 [英] Heroku: "No default language could be detected for this app" error thrown for node app
问题描述
我正在学习 NodeJS,我正在学习的课程有几个按部分排列的项目.我有一个主文件夹下的所有项目,这也是一个
我决定将 todo-api
子文件夹重构为一个新项目,这一次推送到 Heroku 工作得很好 -
我不明白为什么会出现无默认语言"错误,尤其是当两个地方的节点应用程序完全相同时.有什么想法吗?
Heroku 有一组默认的 buildpack,在需要检测应用语言时使用.
为了进行检测,它运行每个默认构建包的 bin/detect
命令,直到其中一个返回 0 退出代码.
这是node buildpack的命令.
如您所见,它要求 package.json
位于应用的根目录,而不是位于子文件夹中.
这是导致构建失败的差异.您需要将您的应用放在 git 存储库的根目录下.
I am learning NodeJS and the course I'm following has several projects, arranged by sections. I have all the projects under one main folder, which is also a git repository.
Each of these subfolders in the main folder is a node project by itself, complete with package.json
and related dependencies in node_modules
. The problem is when I tried to push the node app in one such folder(todo-api
) to heroku, I get the following error -
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'
This is the directory structure for the project -
I decided to refactor out the todo-api
subfolder into a new project all by itself, and this time the push to Heroku works just fine -
I don't understand why I get the "no default language" error, especially when the node app is exactly the same in both places. Any thoughts?
Heroku has a set of default buildpacks, used when it needs to detect the language of your app.
In order to do that detection, it runs the bin/detect
command of each of those default buildpacks, until one of them returns a 0 exit code.
This is the command for the node buildpack.
As you can see, it requires a package.json
to be located at the root of your app, not in a subfolder.
This is the difference causing your build to fail. You need to put your app at the root of your git repository.
这篇关于Heroku:“无法检测到此应用程序的默认语言";为节点应用程序抛出的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!