phantazein phantazein - 3 months ago 14
Node.js Question

Using Heroku for a Node web application

I am trying to set up a project on Heroku. I went through their tutorial for Node apps and I am now trying to use my repository to work on my web app. I have already created the project and it shows up on my Heroku dashboard but I can't push anything to it. This is the message I get every time:

remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Using set buildpack heroku/nodejs
remote:
remote: ! Push rejected, failed to detect set buildpack heroku/nodejs
remote: More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to your_web_app.


I've made sure the buildpack is set to nodejs. I used information from Heroku along with Heroku wrongly detecting my Node app as a Ruby app, but still I cannot deploy.

I also already went into the package.json file and added in my node version under the "engine" section. Why can't I deploy to Heroku still?

EDIT: Here is my package.json file:

{
"name": "node",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"body-parser": "~1.13.2",
"cookie-parser": "~1.3.5",
"debug": "~2.2.0",
"express": "~4.13.1",
"jade": "~1.11.0",
"morgan": "~1.6.1",
"serve-favicon": "~2.3.0"
},
"engines": {
"node": "5.7.0"
}
}

Answer

Ensure following things:

1- app has a package.json file in the root directory.

2- app has node version defined in package.json as:

"engines": {
    "node": "4.1.1"
  },

Edit: buildpacks fix,

heroku buildpacks:clear //clear buildpack

heroku buildpacks:set heroku/nodejs //set correct build pack for node.js app

OR

heroku buildpacks:set https://github.com/heroku/heroku-buildpack-nodejs -a your-app-name