Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku: "No default language could be detected for this app" error thrown for node app

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 -

enter image description here

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 -

enter image description here

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?

like image 905
Manish Giri Avatar asked Apr 12 '17 06:04

Manish Giri


People also ask

When Heroku Cannot detect the Buildpack to use for this application automatically?

Resolution. This error message means that Heroku was unable to automatically detect the type of app you're trying to deploy: Ruby, Node, Python, PHP, Java, etc. We look for signatures for each language we support (like a pom. xml file or package.

How do you run NPM install on Heroku?

Run the npm install command in your local app directory to install the dependencies that you declared in your package. json file. Start your app locally using the heroku local command, which is installed as part of the Heroku CLI. Your app should now be running on http://localhost:5000/.

Does Heroku support Javascript?

Listed on the Heroku reference page, the supported buildpacks offered are: Ruby, Node. js, Clojure, Python, Java, Gradle, Grails, Scala, Play, PHP, Go.


Video Answer


1 Answers

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.

like image 51
Damien MATHIEU Avatar answered Oct 08 '22 14:10

Damien MATHIEU