0

here are my logs

2018-07-19T01:40:27.548845+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/bcrypt/bcrypt.js:6:16)
2018-07-19T01:40:27.548847+00:00 app[web.1]: at Module._compile (module.js:652:30)
2018-07-19T01:40:27.548850+00:00 app[web.1]: at Module.load (module.js:565:32)
2018-07-19T01:40:27.548848+00:00 app[web.1]: at Object.Module._extensions..js (module.js:663:10)
2018-07-19T01:40:27.548851+00:00 app[web.1]: at tryModuleLoad (module.js:505:12)
2018-07-19T01:40:27.548853+00:00 app[web.1]: at Function.Module._load (module.js:497:3)
2018-07-19T01:40:27.548854+00:00 app[web.1]: at Module.require (module.js:596:17)
2018-07-19T01:40:27.548856+00:00 app[web.1]: at require (internal/module.js:11:18)
2018-07-19T01:40:27.548858+00:00 app[web.1]: at Object.<anonymous> (/app/api/routes/users.js:4:16)
2018-07-19T01:40:27.548859+00:00 app[web.1]: at Module._compile (module.js:652:30)
2018-07-19T01:40:27.591620+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2018-07-19T01:40:27.591624+00:00 app[web.1]: npm ERR! errno 1
2018-07-19T01:40:27.592485+00:00 app[web.1]: npm ERR! main-accounting-app@1.0.0 start: `node app.js`
2018-07-19T01:40:27.592488+00:00 app[web.1]: npm ERR! Exit status 1
2018-07-19T01:40:27.595923+00:00 app[web.1]: npm ERR! Failed at the main-accounting-app@1.0.0 start script.
2018-07-19T01:40:27.592490+00:00 app[web.1]: npm ERR!
2018-07-19T01:40:27.596528+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2018-07-19T01:40:27.618466+00:00 app[web.1]:
2018-07-19T01:40:27.619407+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2018-07-19T01:40:27.619410+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2018-07-19T01_40_27_602Z-debug.log
2018-07-19T01:40:27.683715+00:00 heroku[web.1]: Process exited with status 1
2018-07-19T01:40:27.707660+00:00 heroku[web.1]: State changed from starting to crashed
2018-07-19T07:16:42.016935+00:00 heroku[web.1]: State changed from crashed to starting
2018-07-19T07:16:46.448819+00:00 heroku[web.1]: Starting process with command `npm start`
2018-07-19T07:16:49.016333+00:00 app[web.1]:
2018-07-19T07:16:49.016352+00:00 app[web.1]: > main-accounting-app@1.0.0 start /app
2018-07-19T07:16:49.016354+00:00 app[web.1]: > node app.js
2018-07-19T07:16:49.016355+00:00 app[web.1]:
2018-07-19T07:16:49.816284+00:00 app[web.1]: module.js:681
2018-07-19T07:16:49.816323+00:00 app[web.1]: return process.dlopen(module, path._makeLong(filename));
2018-07-19T07:16:49.816325+00:00 app[web.1]: ^
2018-07-19T07:16:49.816326+00:00 app[web.1]:
2018-07-19T07:16:49.816328+00:00 app[web.1]: Error: /app/node_modules/bcrypt/lib/binding/bcrypt_lib.node: invalid ELF header
2018-07-19T07:16:49.816330+00:00 app[web.1]: at Object.Module._extensions..node (module.js:681:18)
2018-07-19T07:16:49.816332+00:00 app[web.1]: at Module.load (module.js:565:32)
2018-07-19T07:16:49.816333+00:00 app[web.1]: at tryModuleLoad (module.js:505:12)
2018-07-19T07:16:49.816335+00:00 app[web.1]: at Function.Module._load (module.js:497:3)
2018-07-19T07:16:49.816336+00:00 app[web.1]: at Module.require (module.js:596:17)
2018-07-19T07:16:49.816338+00:00 app[web.1]: at require (internal/module.js:11:18)
2018-07-19T07:16:49.816339+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/bcrypt/bcrypt.js:6:16)
2018-07-19T07:16:49.816341+00:00 app[web.1]: at Module._compile (module.js:652:30)
2018-07-19T07:16:49.816342+00:00 app[web.1]: at Object.Module._extensions..js (module.js:663:10)
2018-07-19T07:16:49.816344+00:00 app[web.1]: at Module.load (module.js:565:32)
2018-07-19T07:16:49.816345+00:00 app[web.1]: at tryModuleLoad (module.js:505:12)
2018-07-19T07:16:49.816347+00:00 app[web.1]: at Function.Module._load (module.js:497:3)
2018-07-19T07:16:49.816348+00:00 app[web.1]: at Module.require (module.js:596:17)
2018-07-19T07:16:49.816350+00:00 app[web.1]: at require (internal/module.js:11:18)
2018-07-19T07:16:49.816351+00:00 app[web.1]: at Object.<anonymous> (/app/api/routes/users.js:4:16)
2018-07-19T07:16:49.816353+00:00 app[web.1]: at Module._compile (module.js:652:30)
2018-07-19T07:16:49.836368+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2018-07-19T07:16:49.836844+00:00 app[web.1]: npm ERR! errno 1
2018-07-19T07:16:49.838607+00:00 app[web.1]: npm ERR! main-accounting-app@1.0.0 start: `node app.js`
2018-07-19T07:16:49.838827+00:00 app[web.1]: npm ERR! Exit status 1
2018-07-19T07:16:49.839121+00:00 app[web.1]: npm ERR!
2018-07-19T07:16:49.839354+00:00 app[web.1]: npm ERR! Failed at the main-accounting-app@1.0.0 start script.
2018-07-19T07:16:49.839577+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2018-07-19T07:16:49.847895+00:00 app[web.1]:
2018-07-19T07:16:49.848144+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2018-07-19T07:16:49.848330+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2018-07-19T07_16_49_841Z-debug.log
2018-07-19T07:16:49.905428+00:00 heroku[web.1]: Process exited with status 1
2018-07-19T07:16:49.993589+00:00 heroku[web.1]: State changed from starting to crashed
2018-07-19T13:08:57.597790+00:00 heroku[web.1]: State changed from crashed to starting
2018-07-19T13:09:01.146666+00:00 heroku[web.1]: Starting process with command `npm start`
2018-07-19T13:09:04.282556+00:00 app[web.1]:
2018-07-19T13:09:04.282604+00:00 app[web.1]: > main-accounting-app@1.0.0 start /app
2018-07-19T13:09:04.282606+00:00 app[web.1]: > node app.js
2018-07-19T13:09:04.282608+00:00 app[web.1]:
2018-07-19T13:09:05.386813+00:00 app[web.1]: module.js:681
2018-07-19T13:09:05.386865+00:00 app[web.1]: return process.dlopen(module, path._makeLong(filename));
2018-07-19T13:09:05.386867+00:00 app[web.1]: ^
2018-07-19T13:09:05.386869+00:00 app[web.1]:
2018-07-19T13:09:05.386872+00:00 app[web.1]: Error: /app/node_modules/bcrypt/lib/binding/bcrypt_lib.node: invalid ELF header
2018-07-19T13:09:05.386873+00:00 app[web.1]: at Object.Module._extensions..node (module.js:681:18)
2018-07-19T13:09:05.386875+00:00 app[web.1]: at Module.load (module.js:565:32)
2018-07-19T13:09:05.386877+00:00 app[web.1]: at tryModuleLoad (module.js:505:12)
2018-07-19T13:09:05.386878+00:00 app[web.1]: at Function.Module._load (module.js:497:3)
2018-07-19T13:09:05.386880+00:00 app[web.1]: at Module.require (module.js:596:17)
2018-07-19T13:09:05.386881+00:00 app[web.1]: at require (internal/module.js:11:18)
2018-07-19T13:09:05.386883+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/bcrypt/bcrypt.js:6:16)
2018-07-19T13:09:05.386885+00:00 app[web.1]: at Module._compile (module.js:652:30)
2018-07-19T13:09:05.386886+00:00 app[web.1]: at Object.Module._extensions..js (module.js:663:10)
2018-07-19T13:09:05.386888+00:00 app[web.1]: at Module.load (module.js:565:32)
2018-07-19T13:09:05.386889+00:00 app[web.1]: at tryModuleLoad (module.js:505:12)
2018-07-19T13:09:05.386891+00:00 app[web.1]: at Function.Module._load (module.js:497:3)
2018-07-19T13:09:05.386892+00:00 app[web.1]: at Module.require (module.js:596:17)
2018-07-19T13:09:05.386894+00:00 app[web.1]: at require (internal/module.js:11:18)
2018-07-19T13:09:05.386895+00:00 app[web.1]: at Object.<anonymous> (/app/api/routes/users.js:4:16)
2018-07-19T13:09:05.386897+00:00 app[web.1]: at Module._compile (module.js:652:30)
2018-07-19T13:09:05.397833+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2018-07-19T13:09:05.398435+00:00 app[web.1]: npm ERR! errno 1
2018-07-19T13:09:05.400199+00:00 app[web.1]: npm ERR! main-accounting-app@1.0.0 start: `node app.js`
2018-07-19T13:09:05.400493+00:00 app[web.1]: npm ERR! Exit status 1
2018-07-19T13:09:05.400842+00:00 app[web.1]: npm ERR!
2018-07-19T13:09:05.401114+00:00 app[web.1]: npm ERR! Failed at the main-accounting-app@1.0.0 start script.
2018-07-19T13:09:05.401381+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2018-07-19T13:09:05.408887+00:00 app[web.1]:
2018-07-19T13:09:05.409196+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2018-07-19T13:09:05.409421+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2018-07-19T13_09_05_403Z-debug.log
2018-07-19T13:09:05.488426+00:00 heroku[web.1]: Process exited with status 1
2018-07-19T13:09:05.510644+00:00 heroku[web.1]: State changed from starting to crashed
PS C:\Users\USER\Documents\aaa-PROJECTS\Main-accounting-app>

here is my procfile

web: node app.js

here is my appjs

var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
const mongoose = require('mongoose');
const cors = require('cors');
const bodyParser = require('body-parser');


var indexRouter = require('./api/routes/index');
var usersRouter = require('./api/routes/users');

mongoose.connect('mongodb://xxx:xxx.mlab.com:39921/demobusinesshub',{
    // mongodb://localhost:27017/testbusinesshub
    // mongodb://xxx:xxx.mlab.com:39921/demobusinesshub
}).then(c => console.log('connected to db'))
.catch(c => console.log('connection to db error'))

var app = express();
app.use(cors());

app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));

app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

// bodyparser

app.use(bodyParser.json());

app.use('/', indexRouter);
app.use('/users', usersRouter);

const port = process.env.PORT || 3000;
const host = '0.0.0.0';

app.listen(port, host, ()=>{
    console.log('Server started on port '+ port);
});
module.exports = app;

here is my package json

{
  "name": "main-accounting-app",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "start": "node app"
  },

  "author": "Sunmola Ayokunle",
  "license": "ISC",
  "dependencies": {
    "bcrypt": "^2.0.1",
    "body-parser": "^1.18.3",
    "cookie-parser": "~1.4.3",
    "cors": "^2.8.4",
    "debug": "~2.6.9",
    "express": "~4.16.0",
    "http-errors": "~1.6.2",
    "jsonwebtoken": "^8.3.0",
    "mongoose": "^5.1.6",
    "morgan": "~1.9.0"
  }
}

and in my auth file in my angular service

return this.http.post('' + this.domain + 'users/register', newUser, {headers: headers}).pipe(map(res => res.json()));

where in production this.domain = '' //(an empty string)

so i dont get what is wrong, i have literially searched the web and i'm being told to check port etc and i've done all that. at this stage i am really confused and i dont know what to do . also i've ran ng build in my angular terminal and its being bunduled to the public folder of my express application. runing this with heroku local works and gives no errors. also running this with my normal local server works too

ayotycoon
  • 199
  • 2
  • 12
  • can you post your .gitignore file? – DavidCohen Jul 19 '18 at 18:19
  • Based on 'bcrypt_lib.node: invalid ELF header' it looks like something is wrong with the bcrypt module, I would look more at that than I would look at ports. – Adam H Jul 19 '18 at 18:20
  • I don't have a .gitignore file. I already used the command git add . – ayotycoon Jul 19 '18 at 18:22
  • are you pushing your node modules? – Shardul Jul 19 '18 at 18:27
  • just checked and no i am not modified: angular-src (modified content, untracked content) modified: app.js modified: package.json modified: public/3rdpartylicenses.txt modified: public/main.js modified: public/main.js.map modified: public/vendor.js modified: public/vendor.js.map – ayotycoon Jul 19 '18 at 18:28
  • or maybe i was , i ran git rm -r --cached . and i got bunch of stuff with syntaxs like this . rm 'node_modules/qs/test/utils.js' – ayotycoon Jul 19 '18 at 18:30

1 Answers1

0

from this question: question on stackoverflow the problem is that you installed the module bcrypt on windows machine and the heroku machine is linux and you pushed the module to the heroku machine, so the bcrypt dependency will not work.

so to fix it delete the node_modules folder on the heroku machine and add .gitignore file to your project and in the file add this line:

node_modules

and than run: git add . and push to heroku master. so the heroku machine will automatic install your dependencies including bcrypt for linux.

DavidCohen
  • 161
  • 1
  • 6
  • TOTALLY WORKED ! THANK YOU – ayotycoon Jul 19 '18 at 18:54
  • Sorry for taking your time. just noticed that my post requests to my server don't work anymore cannot POST "https://tranquil-brook-74323.herokuapp.com/users/register". and they work with heroku local – ayotycoon Jul 19 '18 at 19:08
  • logs 2018-07-19T18:56:55.523139+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=POST path="/users/login" host=tranquil-brook-74323.herokuapp.com request_id=3e80f6d5-8d3e-4026-bcab-45adab4f2b47 fwd="197.211.59.160" dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=https – ayotycoon Jul 19 '18 at 19:12
  • Working now. i forgot to change the mongo connection from local to my remote database thank you very much – ayotycoon Jul 19 '18 at 19:50