我想将我的应用程序部署到heroku。在本地可行,部署不会引发任何错误。
错误日志显示它无法在主文件夹(节点server.js)中运行启动脚本。
然后,它说找不到猫鼬的模块。
然后抛出H10错误。
在heroku应用页面中:
无法加载资源:服务器响应状态为503(服务不可用)
planit-todo.herokuapp.com/:1
我究竟做错了什么 ?我的heroku的config var具有图集驱动程序,我让Heroku设置了自己的PORT。
My github repository
我已经尝试了所有的stackoverflow解决方案,但是没有运气。
heroku日志--tail如下:
2020-07-22T19:01:36.782713+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:72:18)
2020-07-22T19:01:36.782713+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:1:18)
2020-07-22T19:01:36.782713+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1138:30)
2020-07-22T19:01:36.782714+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
2020-07-22T19:01:36.782714+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:986:32)
2020-07-22T19:01:36.782714+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:879:14)
2020-07-22T19:01:36.782715+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
2020-07-22T19:01:36.782715+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2020-07-22T19:01:36.782716+00:00 app[web.1]: requireStack: [ '/app/server.js' ]
2020-07-22T19:01:36.782716+00:00 app[web.1]: }
2020-07-22T19:01:36.795140+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-07-22T19:01:36.795530+00:00 app[web.1]: npm ERR! errno 1
2020-07-22T19:01:36.796942+00:00 app[web.1]: npm ERR! back-end@0.0.0 start: `node server.js`
2020-07-22T19:01:36.797085+00:00 app[web.1]: npm ERR! Exit status 1
2020-07-22T19:01:36.797372+00:00 app[web.1]: npm ERR!
2020-07-22T19:01:36.797591+00:00 app[web.1]: npm ERR! Failed at the back-end@0.0.0 start script.
2020-07-22T19:01:36.797824+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-07-22T19:01:36.809789+00:00 app[web.1]:
2020-07-22T19:01:36.810057+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-07-22T19:01:36.810171+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-07-22T19_01_36_799Z-debug.log
2020-07-22T19:01:36.893334+00:00 heroku[web.1]: Process exited with status 1
2020-07-22T19:01:36.938082+00:00 heroku[web.1]: State changed from starting to crashed
2020-07-22T19:05:36.690194+00:00 heroku[web.1]: State changed from crashed to starting
2020-07-22T19:05:44.866625+00:00 heroku[web.1]: Starting process with command `npm start`
2020-07-22T19:05:47.474291+00:00 app[web.1]:
2020-07-22T19:05:47.474311+00:00 app[web.1]: > back-end@0.0.0 start /app
2020-07-22T19:05:47.474312+00:00 app[web.1]: > node server.js
2020-07-22T19:05:47.474312+00:00 app[web.1]:
2020-07-22T19:05:47.537443+00:00 app[web.1]: internal/modules/cjs/loader.js:969
2020-07-22T19:05:47.537444+00:00 app[web.1]: throw err;
2020-07-22T19:05:47.537444+00:00 app[web.1]: ^
2020-07-22T19:05:47.537444+00:00 app[web.1]:
2020-07-22T19:05:47.537445+00:00 app[web.1]: Error: Cannot find module 'mongoose'
2020-07-22T19:05:47.537445+00:00 app[web.1]: Require stack:
2020-07-22T19:05:47.537445+00:00 app[web.1]: - /app/server.js
2020-07-22T19:05:47.537446+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
2020-07-22T19:05:47.537446+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:842:27)
2020-07-22T19:05:47.537446+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:1026:19)
2020-07-22T19:05:47.537447+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:72:18)
2020-07-22T19:05:47.537447+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:1:18)
2020-07-22T19:05:47.537447+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1138:30)
2020-07-22T19:05:47.537447+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
2020-07-22T19:05:47.537448+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:986:32)
2020-07-22T19:05:47.537448+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:879:14)
2020-07-22T19:05:47.537448+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
2020-07-22T19:05:47.537448+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2020-07-22T19:05:47.537449+00:00 app[web.1]: requireStack: [ '/app/server.js' ]
2020-07-22T19:05:47.537449+00:00 app[web.1]: }
2020-07-22T19:05:47.542945+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-07-22T19:05:47.543142+00:00 app[web.1]: npm ERR! errno 1
2020-07-22T19:05:47.544039+00:00 app[web.1]: npm ERR! back-end@0.0.0 start: `node server.js`
2020-07-22T19:05:47.544128+00:00 app[web.1]: npm ERR! Exit status 1
2020-07-22T19:05:47.544241+00:00 app[web.1]: npm ERR!
2020-07-22T19:05:47.544337+00:00 app[web.1]: npm ERR! Failed at the back-end@0.0.0 start script.
2020-07-22T19:05:47.544407+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-07-22T19:05:47.549143+00:00 app[web.1]:
2020-07-22T19:05:47.549276+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-07-22T19:05:47.549360+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-07-22T19_05_47_545Z-debug.log
2020-07-22T19:05:47.597385+00:00 heroku[web.1]: Process exited with status 1
2020-07-22T19:05:47.645927+00:00 heroku[web.1]: State changed from starting to crashed
2020-07-22T19:05:47.648768+00:00 heroku[web.1]: State changed from crashed to starting
2020-07-22T19:06:00.718086+00:00 heroku[web.1]: Starting process with command `npm start`
2020-07-22T19:06:04.676187+00:00 app[web.1]:
2020-07-22T19:06:04.676207+00:00 app[web.1]: > back-end@0.0.0 start /app
2020-07-22T19:06:04.676208+00:00 app[web.1]: > node server.js
2020-07-22T19:06:04.676208+00:00 app[web.1]:
2020-07-22T19:06:04.926363+00:00 app[web.1]: internal/modules/cjs/loader.js:969
2020-07-22T19:06:04.926364+00:00 app[web.1]: throw err;
2020-07-22T19:06:04.926365+00:00 app[web.1]: ^
2020-07-22T19:06:04.926365+00:00 app[web.1]:
2020-07-22T19:06:04.926365+00:00 app[web.1]: Error: Cannot find module 'mongoose'
2020-07-22T19:06:04.926366+00:00 app[web.1]: Require stack:
2020-07-22T19:06:04.926366+00:00 app[web.1]: - /app/server.js
2020-07-22T19:06:04.926367+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
2020-07-22T19:06:04.926367+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:842:27)
2020-07-22T19:06:04.926368+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:1026:19)
2020-07-22T19:06:04.926368+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:72:18)
2020-07-22T19:06:04.926369+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:1:18)
2020-07-22T19:06:04.926369+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1138:30)
2020-07-22T19:06:04.926369+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
2020-07-22T19:06:04.926376+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:986:32)
2020-07-22T19:06:04.926377+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:879:14)
2020-07-22T19:06:04.926377+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
2020-07-22T19:06:04.926377+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2020-07-22T19:06:04.926378+00:00 app[web.1]: requireStack: [ '/app/server.js' ]
2020-07-22T19:06:04.926378+00:00 app[web.1]: }
2020-07-22T19:06:04.970722+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-07-22T19:06:04.971229+00:00 app[web.1]: npm ERR! errno 1
2020-07-22T19:06:04.973330+00:00 app[web.1]: npm ERR! back-end@0.0.0 start: `node server.js`
2020-07-22T19:06:04.977895+00:00 app[web.1]: npm ERR! Exit status 1
2020-07-22T19:06:04.977897+00:00 app[web.1]: npm ERR!
2020-07-22T19:06:04.977898+00:00 app[web.1]: npm ERR! Failed at the back-end@0.0.0 start script.
2020-07-22T19:06:04.977899+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-07-22T19:06:05.045226+00:00 app[web.1]:
2020-07-22T19:06:05.045236+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-07-22T19:06:05.045237+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-07-22T19_06_04_976Z-debug.log
2020-07-22T19:06:05.134182+00:00 heroku[web.1]: Process exited with status 1
2020-07-22T19:06:05.187788+00:00 heroku[web.1]: State changed from starting to crashed
2020-07-22T19:06:06.406418+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=planit-todo.herokuapp.com request_id=9034d699-1035-4f3d-ad15-5b1c707f59be fwd="181.116.229.111" dyno= connect= service= status=503 bytes= protocol=https
2020-07-22T19:06:07.525520+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=planit-todo.herokuapp.com request_id=4a6f4ece-503d-4723-b310-0415d0a1b6ce fwd="181.116.229.111" dyno= connect= service= status=503 bytes= protocol=https