0

I am doing a nodejs course and am not able to deploy app to heroku. The App stack is nodejs, express, mongodb. The Problem I am getting a Process exited with status 1 from heroku after pushing my code. Here is my app configuration for connecting to database.

module.exports=function(){
  let db = config.get('db');
  if(process.env.NODE_ENV === 'production'){
    db = process.env.MONGODB_URI;
  }
mongoose.connect(db)
  .then(() => winston.info(`Connected to ${db}...`));
}

my config vars in heroku

MONGODB_URI mongodb+srv://vidlyuser:password@cluster0-b8ezs.mongodb.net/test?retryWrites=true&w=majority
NODE_ENV production
NPM_CONFIG_LOGLEVEL verbose

My greatest challenge is that heroku error logs are not as helpful.

State changed from starting to crashed
Process exited with status 1

heroku logs --tail

2020-03-23T07:10:56.519157+00:00 app[web.1]: npm ERR! Failed at the vidly@1.0.0 start script.
2020-03-23T07:10:56.519289+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-03-23T07:10:56.519715+00:00 app[web.1]: npm verb exit [ 1, true ]
2020-03-23T07:10:56.533850+00:00 app[web.1]: npm timing npm Completed in 1161ms
2020-03-23T07:10:56.534215+00:00 app[web.1]: 
2020-03-23T07:10:56.534554+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-03-23T07:10:56.534856+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2020-03-23T07_10_56_520Z-debug.log
2020-03-23T07:10:56.609864+00:00 heroku[web.1]: State changed from starting to crashed
2020-03-23T07:10:56.592043+00:00 heroku[web.1]: Process exited with status 1

Followed Heroku Node.js app "Process exited with status 1" and error h10. But no change.

this npm ERR! code ELIFECYCLE didnt help either

GoldenretriverYT
  • 3,043
  • 1
  • 9
  • 22
Mats_invasion
  • 117
  • 1
  • 2
  • 12

2 Answers2

1

I think you need to remove the original env file and redo it

heroku config:set MONGODB_URI=mongodb+srv://vidlyuser:password@cluster0-b8ezs.mongodb.net/test?retryWrites=true&w=majority

heroku config:set NPM_CONFIG_LOGLEVEL=verbose
Sagar Ghimire
  • 231
  • 4
  • 10
0

In my effort to fix this issue i learnt that i miss understood the error. i learnt The error npm ERR! Failed at the vidly@1.0.0 start script. usually points to an underlying error. making use of exception logging in my code i was able to discover the actual error and this had to do with a particular npm package.

The solution is npm ERR! Failed at the vidly@1.0.0 start script. usually points to another error.

Mats_invasion
  • 117
  • 1
  • 2
  • 12