2

I tried pushing my node.js application on heroku but. No default language could be detected for this app. I even tried heroku buildpacks:set heroku/nodejs. But still unable to push.

 Counting objects: 31, done.
    Delta compression using up to 4 threads.
    Compressing objects: 100% (24/24), done.
    Writing objects: 100% (31/31), 5.37 KiB | 0 bytes/s, done.
    Total 31 (delta 3), reused 0 (delta 0)
    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 radiant-cliffs-91678.
    remote: 
    To https://git.heroku.com/radiant-cliffs-91678.git
     ! [remote rejected] master -> master (pre-receive hook declined)
    error: failed to push some refs to 'https://git.heroku.com/radiant-cliffs-91678.git'
Ankit Kumar
  • 193
  • 2
  • 10

2 Answers2

5

Based on your logs, it looks like Heroku can't detect the language of your app.

For Node.js, you need to either create a package.json file in the root your project (using something like npm init), or you can create a Procfile in the root of your project to specify your language:

web: node index.js
Steven Schobert
  • 4,201
  • 3
  • 25
  • 34
  • I have both package.json as well as Procfile – Ankit Kumar Sep 22 '16 at 16:27
  • 1
    Are both of these files in the root directory of your project? – Steven Schobert Sep 22 '16 at 16:28
  • Also, are you pushing the master branch of your project where those files are committed? – Steven Schobert Sep 22 '16 at 16:30
  • I have 2 folders angular and backend, both my package.json and procfile is in backend folder – Ankit Kumar Sep 22 '16 at 16:42
  • @AnkitKumar Ah thats why then. Heroku only looks in the top-most folder. You need to have the Procfile in the root. Then in the Procfile point it to `web: node backend/index.js` or whatever the relative path of your starting file is. – Steven Schobert Sep 22 '16 at 16:56
  • thanks what about node_modules? do I have to remove gitignore? – Ankit Kumar Sep 22 '16 at 16:58
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/123974/discussion-between-steven-schobert-and-ankit-kumar). – Steven Schobert Sep 22 '16 at 17:09
  • 1
    This is partly correct, but `Procfile`s are not used to determine the language for an application. Each buildpack defines the file(s) required to be compatible with the buildpack, and for Node.js [the only file that counts is `package.json` in the root directory](https://github.com/heroku/heroku-buildpack-nodejs/blob/221ed07d8c30a898725f2dd560d3c0afbda9ae79/bin/detect#L22). `Procfile`s only define process types and their commands. – ChrisGPT was on strike Nov 21 '22 at 17:36
-4

go to command line and run following command :

heroku buildpacks:set -a app_name heroku/node
Neha Mangla
  • 1,042
  • 3
  • 13
  • 24