【发布时间】: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 也没有帮助
【问题讨论】: