Heroku 错误代码:Elifecycle +更多未知数

Posted

技术标签:

【中文标题】Heroku 错误代码:Elifecycle +更多未知数【英文标题】:Heroku error code: Elifecycle +more unknowns 【发布时间】:2019-09-27 21:26:02 【问题描述】:

我正在尝试使用 Heroku 启动我的 MERN 堆栈应用程序,它可以在我的本地主机上运行,​​但是按照 heroku 的指示,我不断收到这个 H10 错误,我觉得这是我错过的一些微不足道的事情。我碰壁了。 我查看了日志,没有任何帮助,更改了 URL,更新了 package.json。我原来pkg.json太多(主文件夹一个,前后端各一个),删除了主文件夹pkg.json,不是节点错误

heroku logs
2019-05-06T01:22:20.905343+00:00 heroku[web.1]: State changed from crashed to starting
2019-05-06T01:22:20.635909+00:00 app[web.1]: > coding-challenge@1.0.0 start /app
2019-05-06T01:22:20.635910+00:00 app[web.1]: > node server.js
2019-05-06T01:22:20.826762+00:00 app[web.1]: internal/modules/cjs/loader.js:611
2019-05-06T01:22:20.826766+00:00 app[web.1]: throw err;
2019-05-06T01:22:20.826768+00:00 app[web.1]: ^
2019-05-06T01:22:20.826771+00:00 app[web.1]: Error: Cannot find module 'cors'
2019-05-06T01:22:20.826773+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:609:15)
2019-05-06T01:22:20.826775+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:535:25)
2019-05-06T01:22:20.826776+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:663:17)
2019-05-06T01:22:20.826777+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:20:18)
2019-05-06T01:22:20.826779+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:4:14)
2019-05-06T01:22:20.826780+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:734:30)
2019-05-06T01:22:20.826781+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:745:10)
2019-05-06T01:22:20.826782+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:626:32)
2019-05-06T01:22:20.826783+00:00 app[web.1]: at tryModuleLoad (internal/modules/cjs/loader.js:566:12)
2019-05-06T01:22:20.826785+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:558:3)
2019-05-06T01:22:20.833856+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-05-06T01:22:20.834362+00:00 app[web.1]: npm ERR! errno 1
2019-05-06T01:22:20.835547+00:00 app[web.1]: npm ERR! coding-challenge@1.0.0 start: `node server.js`
2019-05-06T01:22:20.835696+00:00 app[web.1]: npm ERR! Exit status 1
2019-05-06T01:22:20.835933+00:00 app[web.1]: npm ERR!
2019-05-06T01:22:20.836101+00:00 app[web.1]: npm ERR! Failed at the coding-challenge@1.0.0 start script.
2019-05-06T01:22:20.836250+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-05-06T01:22:20.843776+00:00 app[web.1]: 
2019-05-06T01:22:20.843920+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-05-06T01:22:20.844004+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2019-05-06T01_22_20_837Z-debug.log
2019-05-06T01:22:20.885179+00:00 heroku[web.1]: Process exited with status 1
2019-05-06T01:22:23.822929+00:00 heroku[web.1]: Starting process with command `npm start`
2019-05-06T01:22:26.506313+00:00 heroku[web.1]: State changed from starting to crashed
2019-05-06T01:22:26.221158+00:00 app[web.1]: 
2019-05-06T01:22:26.221187+00:00 app[web.1]: > coding-challenge@1.0.0 start /app
2019-05-06T01:22:26.221190+00:00 app[web.1]: > node server.js
2019-05-06T01:22:26.221192+00:00 app[web.1]: 
2019-05-06T01:22:26.431669+00:00 app[web.1]: internal/modules/cjs/loader.js:611
2019-05-06T01:22:26.431673+00:00 app[web.1]: throw err;
2019-05-06T01:22:26.431674+00:00 app[web.1]: ^
2019-05-06T01:22:26.431676+00:00 app[web.1]: 
2019-05-06T01:22:26.431678+00:00 app[web.1]: Error: Cannot find module 'cors'
2019-05-06T01:22:26.431680+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:609:15)
2019-05-06T01:22:26.431682+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:535:25)
2019-05-06T01:22:26.431684+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:663:17)
2019-05-06T01:22:26.431687+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:20:18)
2019-05-06T01:22:26.431688+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:4:14)
2019-05-06T01:22:26.431690+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:734:30)
2019-05-06T01:22:26.431692+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:745:10)
2019-05-06T01:22:26.431694+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:626:32)
2019-05-06T01:22:26.431695+00:00 app[web.1]: at tryModuleLoad (internal/modules/cjs/loader.js:566:12)
2019-05-06T01:22:26.431697+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:558:3)
2019-05-06T01:22:26.438865+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-05-06T01:22:26.439262+00:00 app[web.1]: npm ERR! errno 1
2019-05-06T01:22:26.440416+00:00 app[web.1]: npm ERR! coding-challenge@1.0.0 start: `node server.js`
2019-05-06T01:22:26.440555+00:00 app[web.1]: npm ERR! Exit status 1
2019-05-06T01:22:26.440783+00:00 app[web.1]: npm ERR!
2019-05-06T01:22:26.440937+00:00 app[web.1]: npm ERR! Failed at the coding-challenge@1.0.0 start script.
2019-05-06T01:22:26.441081+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-05-06T01:22:26.448596+00:00 app[web.1]: 
2019-05-06T01:22:26.448750+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-05-06T01:22:26.448803+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2019-05-06T01_22_26_442Z-debug.log
2019-05-06T01:22:26.493385+00:00 heroku[web.1]: Process exited with status 1
2019-05-06T01:45:52.690438+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=intense-wildwood-76480.herokuapp.com request_id=b1c76bb1-2948-45cd-929b-b579eb45e29b fwd="24.192.243.229" dyno= connect= service= status=503 bytes= protocol=https
2019-05-06T01:45:54.362863+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=intense-wildwood-76480.herokuapp.com request_id=df6c81f1-df99-4d50-af11-baff32648e77 fwd="24.192.243.229" dyno= connect= service= status=503 bytes= protocol=https
2019-05-06T01:53:45.184100+00:00 heroku[web.1]: State changed from crashed to starting
2019-05-06T01:53:48.182538+00:00 heroku[web.1]: Starting process with command `npm start`
2019-05-06T01:53:51.404026+00:00 heroku[web.1]: State changed from starting to crashed
2019-05-06T01:53:50.980526+00:00 app[web.1]: 
2019-05-06T01:53:50.980548+00:00 app[web.1]: > coding-challenge@1.0.0 start /app
2019-05-06T01:53:50.980551+00:00 app[web.1]: > node server.js
2019-05-06T01:53:50.980552+00:00 app[web.1]: 
2019-05-06T01:53:51.263052+00:00 app[web.1]: internal/modules/cjs/loader.js:611
2019-05-06T01:53:51.263083+00:00 app[web.1]: throw err;
2019-05-06T01:53:51.263084+00:00 app[web.1]: ^
2019-05-06T01:53:51.263086+00:00 app[web.1]: 
2019-05-06T01:53:51.263087+00:00 app[web.1]: Error: Cannot find module 'cors'
2019-05-06T01:53:51.263089+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:609:15)
2019-05-06T01:53:51.263091+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:535:25)
2019-05-06T01:53:51.263093+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:663:17)
2019-05-06T01:53:51.263094+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:20:18)
2019-05-06T01:53:51.263096+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:4:14)
2019-05-06T01:53:51.263097+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:734:30)
2019-05-06T01:53:51.263099+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:745:10)
2019-05-06T01:53:51.263100+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:626:32)
2019-05-06T01:53:51.263102+00:00 app[web.1]: at tryModuleLoad (internal/modules/cjs/loader.js:566:12)
2019-05-06T01:53:51.263103+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:558:3)
2019-05-06T01:53:51.274764+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-05-06T01:53:51.274769+00:00 app[web.1]: npm ERR! errno 1
2019-05-06T01:53:51.278740+00:00 app[web.1]: npm ERR! coding-challenge@1.0.0 start: `node server.js`
2019-05-06T01:53:51.278744+00:00 app[web.1]: npm ERR! Exit status 1
2019-05-06T01:53:51.278746+00:00 app[web.1]: npm ERR!
2019-05-06T01:53:51.278748+00:00 app[web.1]: npm ERR! Failed at the coding-challenge@1.0.0 start script.
2019-05-06T01:53:51.278750+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-05-06T01:53:51.287320+00:00 app[web.1]: 
2019-05-06T01:53:51.287325+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-05-06T01:53:51.287327+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2019-05-06T01_53_51_279Z-debug.log
2019-05-06T01:53:51.386095+00:00 heroku[web.1]: Process exited with status 1
2019-05-06T02:07:06.872526+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=intense-wildwood-76480.herokuapp.com request_id=c14c2030-244d-469e-8953-d99d8e1d6fe8 fwd="24.192.243.229" dyno= connect= service= status=503 bytes= protocol=https
2019-05-06T02:07:08.695039+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=intense-wildwood-76480.herokuapp.com request_id=3532bee8-9b55-43ed-87ec-9bd7c2706efb fwd="24.192.243.229" dyno= connect= service= status=503 bytes= protocol=https

【问题讨论】:

这很简单......你没有运行npm install(或heroku,出于某种原因) 【参考方案1】:

看起来模块 cors 尚未安装。我认为 Heroku 应该在你的项目中自动为你运行 npm install,但是你必须在你的 package.json 中列出依赖项。

package.json 内,dependencies 对象内是否有 cors 依赖项?如果不是,您应该添加它,使其看起来像

// package.json

  "dependencies": 
    "cors": "*"
  

【讨论】:

以上是关于Heroku 错误代码:Elifecycle +更多未知数的主要内容,如果未能解决你的问题,请参考以下文章

错误删除“CR”更漂亮/更漂亮的 Visual Studio 代码

(错误域=NSPOSIXErrorDomain 代码=100“协议错误”

如何从 NSError 代码中找到错误描述?

Python小练习更改版(更改一部分代码,与错误)

编写HTML代码常见错误以及解决方法?

合并排序代码中的分段错误