Using Heroku for a Node web application

三世轮回 提交于 2019-12-25 05:36:16

问题


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"
  }
}

回答1:


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



来源:https://stackoverflow.com/questions/35816242/using-heroku-for-a-node-web-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!