Heroku: "Unable to determine the default language for this application" error generated for node application
I am learning NodeJS and the course I am studying has several projects grouped into sections. I have all projects in one main folder, which is also a git repository .
Each of these subfolders in the main folder is a site project of its own, complete with package.json
and associated dependencies in node_modules
. The problem is that when I tried to send a node application to one of such folders ( todo-api
) in 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 convert the subfolder todo-api
to a new project myself and this time migrating to Heroku works just fine -
I don't understand why I am getting a "no default language" error, especially when the host application is the same in both places. Any thoughts?
source to share
Heroku has a set of standard packages used in determining the language of your application.
To perform this detection, it runs a command on bin/detect
each of these standard packages until one of them returns an exit code of 0.
This is the command for node buildpack .
As you can see, it is required to be placed in the root of your application package.json
, not in a subfolder.
This is the difference that causes the loss of assembly. You need to host your application in the root directory of the git repository.
source to share
In my case, I didn't set up Heroku in the root folder because my GitHub repository was split into frontend / and backend / folders. They each had a .json package. Since Heroku needs a package.json file in the root folder of the repository, it cannot detect the language.
In my case, I had to initialize a secondary GitHub repository in the backend / folder. After the backend project was ported to GitHub as a separate project git push heroku master
worked.
source to share