Heroku: "No default language could be detected for this app" error thrown for node app
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.
In my case, I hadn't Heroku set up in the root folder, because my GitHub repository was split up into frontend/ and backend/ folders. Each of them had a package.json. Since Heroku needs the 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 pushed to GitHub as separate project, git push heroku master
worked.
In my case I had pending files needs to be committed to github :)
You need to set a language for the project. Without using the terminal, go to Heroku project. Click on settings, scroll down Build Backbacks and add a language (nodejs, etc).
I got the same message
No default language could be detected for this app.
I was on a different branch than master when deploying. That's why it didn't work.
I changed branch to master and it worked.
Don't forget to put "start" : "node app.js" in the scripts of package.json
Otherwise you will get H10 code error.
The app then worked.