【问题标题】:Heroku, NodeJS, MongoDB, process exited status 1Heroku,NodeJS,MongoDB,进程退出状态 1
【发布时间】:2020-07-03 15:57:18
【问题描述】:

我正在学习 nodejs 课程,但无法将应用程序部署到 heroku。应用栈是nodejs、express、mongodb。 问题 推送我的代码后,我从 heroku 收到了Process exited with status 1。 这是我连接数据库的应用配置。

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}...`));
}

我在 heroku 中的配置变量

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

我最大的挑战是 heroku 错误日志没有那么有用。

State changed from starting to crashed
Process exited with status 1

heroku 日志 --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

已关注Heroku Node.js app "Process exited with status 1" and error h10。但没有变化。

这个npm ERR! code ELIFECYCLE 也没有帮助

【问题讨论】:

    标签: node.js mongodb heroku


    【解决方案1】:

    我认为你需要删除原始的env文件并重做它

    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
    

    【讨论】:

    • 我认为这是 Mosh Hamedani 的课程,如果你很好地遵循他的教程,就不会有任何问题
    • 就是那个。但它是 2 年前制作的。所以问题确实出现了。因为我一直追到最后
    【解决方案2】:

    在我努力解决这个问题的过程中,我了解到我错过了理解错误。我了解到错误npm ERR! Failed at the vidly@1.0.0 start script. 通常指向一个潜在的错误。在我的代码中使用异常日志记录,我能够发现实际的错误,这与特定的 npm 包有关。

    解决方法是npm ERR! Failed at the vidly@1.0.0 start script. 通常指向另一个错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-25
      • 2020-10-18
      • 1970-01-01
      • 2017-09-28
      • 1970-01-01
      • 1970-01-01
      • 2015-03-11
      • 2020-10-24
      相关资源
      最近更新 更多