Unable to deploy heroku using nodejs

I am trying to drag local files into the hero and get below errors. I have code in github

Can someone help me with this. Thanks

$ heroku buildpacks:set heroku/nodejs
Buildpack set. Next release on haz will use heroku/nodejs.
Run git push heroku master to create a new release using this buildpack.
$ git push heroku master
Counting objects: 693, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (500/500), done.
Writing objects: 100% (693/693), 63.10 MiB | 2.54 MiB/s, done.
Total 693 (delta 220), reused 639 (delta 171)
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 haz.
remote: 
To https://git.heroku.com/haz.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/haz.git'
$ 

for package.json

{
  "name": "haz",
  "version": "1.0.0",
  "description": "Hazzir: An Ionic project",
  "private": "true",
  "dependencies": {
    "express": "^4.13.3"    
  },
  "main": "serve.js",
  "scripts": {
    "start": "node serve.js",
    "postinstall": "bower install && grunt build",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "engines": {
      "node": "4.1.2",
      "npm": "3.4.0"
    },

  "keywords": [
    "Haz",
    "product"
  ],
  "author": "Asim Khan",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/asimkh/apps/issues"
  },
  "homepage": "https://github.com/asimkh/apps#readme"
}

I tested locally, the application runs on port 5000 using express

var express = require('express'),
    app = express();

app.use(express.static('www'));

// CORS (Cross-Origin Resource Sharing) headers to support Cross-site HTTP requests
app.all('*', function(req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "X-Requested-With");
    next();
});

// API Routes
// app.get('/blah', routeHandler);

app.set('port', process.env.PORT || 5000);

app.listen(app.get('port'), function () {
    console.log('Express server listening on port ' + app.get('port'));
});
+4
source share
3 answers

I see several problems here.

1) You need a procfile - https://devcenter.heroku.com/articles/getting-started-with-nodejs#define-a-procfile

2) You do not specify engines in your package. Json

"engines": {
  "node": "0.10.x"
},

https://discussion.heroku.com/t/the-official-node-js-buildpack-is-going-on-a-diet/100

3) node_modules git. npm install ( packages.json)

git. .gitignore. .gitignore:

node_modules

.gitignore .

Git node_modules_

+4

: git add -f package.json .

+1

git init, heroku

heroku git:remote -a yourappname
0

Source: https://habr.com/ru/post/1616356/


All Articles