Javascript Heroku Node.js应用程序;进程已退出,状态为“1”;和错误h10

Javascript Heroku Node.js应用程序;进程已退出,状态为“1”;和错误h10,javascript,node.js,heroku,Javascript,Node.js,Heroku,我将我的应用程序部署到heroku上,没有问题。我能够在localhost:5000上运行heroku local web,并且运行正常。当我转到web dyno地址时,它说应用程序错误。我查看了网站的日志,上面写着: 2017-05-01T02:52:30.980217+00:00 app[web.1]: at Connection.<anonymous> (/app/node_modules/mongodb-core/lib/connection/pool.js:274

我将我的应用程序部署到heroku上,没有问题。我能够在localhost:5000上运行heroku local web,并且运行正常。当我转到web dyno地址时,它说应用程序错误。我查看了网站的日志,上面写着:

 2017-05-01T02:52:30.980217+00:00 app[web.1]:     at Connection.<anonymous> (/app/node_modules/mongodb-core/lib/connection/pool.js:274:12)
 2017-05-01T02:52:30.980218+00:00 app[web.1]:     at emitTwo (events.js:106:13)
 2017-05-01T02:52:30.980218+00:00 app[web.1]:     at Socket.<anonymous> (/app/node_modules/mongodb-core/lib/connection/connection.js:177:49)
 2017-05-01T02:52:30.980218+00:00 app[web.1]:     at Connection.emit (events.js:191:7)
 2017-05-01T02:52:30.980219+00:00 app[web.1]:     at emitOne (events.js:96:13)
 2017-05-01T02:52:30.980220+00:00 app[web.1]:     at Socket.emit (events.js:188:7)
 2017-05-01T02:52:30.980221+00:00 app[web.1]:     at process._tickCallback (internal/process/next_tick.js:104:9)
 2017-05-01T02:52:31.040828+00:00 heroku[web.1]: State changed from starting to crashed
 2017-05-01T02:52:31.029211+00:00 heroku[web.1]: Process exited with status 1
 2017-05-01T02:52:40.638415+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=room111-thoughts.herokuapp.com request_id=91b591cf-3d8d-4d94-8caf-7b1b868b088b fwd="108.221.62.78" dyno= connect= service= status=503 bytes= protocol=https
 2017-05-01T02:52:41.600924+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=room111-thoughts.herokuapp.com request_id=c8f6c2d3-dc38-4e65-9a20-581910f42b36 fwd="108.221.62.78" dyno= connect= service= status=503 bytes= protocol=https

通过调用heroku config检查环境变量DB_URI,并查看为其列出的内容。该错误表示您的连接被拒绝,因此我猜测没有配置mongo db,或者没有在heroku应用程序上下文中设置环境变量

我也有同样的问题。我没有使用mongo db,但错误是相同的:

2018-01-23T09:30:10.806568+00:00 heroku[web.1]: Process exited with status 1
2018-01-23T09:30:10.823360+00:00 heroku[web.1]: State changed from starting to crashed
2018-01-23T09:30:32.001596+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/"....
该应用程序在本地主机上运行良好,但在heroku上部署时崩溃。 Heroku网站日志页面根本帮不上忙,所以我在本地通过命令行尝试:
Heroku日志--tail
,许多未显示在网站中的日志出现了。这些日志说:

2018-01-23T09:30:09.431324+00:00 heroku[web.1]: Starting process with command `node server.js`
2018-01-23T09:30:10.771449+00:00 app[web.1]: module.js:540
2018-01-23T09:30:10.771465+00:00 app[web.1]:     throw err;
2018-01-23T09:30:10.771466+00:00 app[web.1]:     ^
2018-01-23T09:30:10.771468+00:00 app[web.1]:
2018-01-23T09:30:10.771470+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:538:15)
2018-01-23T09:30:10.771469+00:00 app[web.1]: Error: Cannot find module 'express'
我意识到我必须安装express,所以我运行:

npm install express
git push heroku master
heroku open 
它成功了。
希望它也能为你工作

对我来说,上面关于环境变量的答案是它。Mine与变量MONGODB_URI有关,该变量未在heroku中设置为环境变量,并且运行heroku config返回的cli中没有变量

修复程序正在运行: heroku插件:创建mongolab:sandbox

如果需要heroku push,那么heroku配置现在应该显示您的.env变量