【问题标题】:Application logs heroku app crashed应用程序日志 heroku 应用程序崩溃
【发布时间】:2019-01-03 10:15:13
【问题描述】:

我在 heroku 中的应用程序有问题。有人可以帮我处理这个日志吗?

2018-07-26T08:40:49.427912+00:00 应用程序 [web.1]:npm 错误! myreads@1.0.1 开始:react-scripts start

2018-07-26T08:40:49.428082+00:00 app[web.1]: npm 错误!生成 ENOENT

2018-07-26T08:40:49.428347+00:00 app[web.1]: npm ERR!

2018-07-26T08:40:49.428831+00:00 应用程序 [web.1]:npm 错误!在 myreads@1.0.1 启动脚本中失败。

2018-07-26T08:40:49.429027+00:00 应用程序 [web.1]:npm 错误!这可能不是 npm 的问题。上面可能还有额外的日志输出。

2018-07-26T08:40:49.436775+00:00 应用[web.1]:

2018-07-26T08:40:49.437011+00:00 app[web.1]: npm 错误!可以在以下位置找到此运行的完整日志:

2018-07-26T08:40:49.437188+00:00 应用程序 [web.1]:npm 错误! /app/.npm/_logs/2018-07-26T08_40_49_430Z-debug.log

2018-07-26T11:56:02.600061+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=my-books-reads.herokuapp .com request_id=6ebca156-9e51-4be5-817e-8d85c3d49dcd fwd="177.107.242.1" dyno= connect= service= status=503 bytes= protocol=https

2018-07-26T11:56:03.098985+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=my-books- reads.herokuapp.com request_id=b8af4900-60a2-4edf-a4db-2113e9cddaec fwd="177.107.242.1" dyno= connect= service= status=503 bytes= protocol=https

【问题讨论】:

    标签: node.js reactjs heroku npm react-router


    【解决方案1】:

    react-scripts 默认是 CRA 应用程序的 devDependency,但 Heroku Node buildpack 的环境 NODE_ENV=production 会导致 npm install 跳过 devDependencies。

    也安装这些 devDependencies:

    将此脚本添加到您的 package.json 中: "heroku-postbuild": "npm install --only=dev"

    试试这个,我觉得应该可以解决问题

    【讨论】:

      【解决方案2】:

      你能检查一下你是否在硬编码你的端口号吗? 如果是这样,请尝试以下代码

      app.listen(process.env.PORT || 3000);
      

      或者运行下面的命令

      heroku restart
      

      【讨论】:

      • 我的代码是这样的exports.port = process.env.PORT || 3001 app.listen(config.port, () => { console.log('服务器监听端口%s, Ctrl+C停止', config.port) })
      • 您是否在应用程序中的其他任何位置(如配置文件)声明了端口号?
      猜你喜欢
      • 2014-03-31
      • 1970-01-01
      • 1970-01-01
      • 2019-02-06
      • 2011-10-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多