首页 > 解决方案 > 有谁明白为什么我的 Heroku 构建可能会失败?

问题描述

我可以推送到 Heroku。当我运行时heroku open,我在浏览器页面上收到应用程序错误。它建议我运行heroku logs --tail,我已经完成了,并且在我的 CLI 中得到了以下内容:

2020-02-18T13:38:17.617747+00:00 app[api]: Release v2 created by user myemail@gmail.com
2020-02-18T13:38:17.617747+00:00 app[api]: Enable Logplex by user myemail@gmail.com
2020-02-18T13:38:16.539707+00:00 app[api]: Initial release by user myemail@gmail.com
2020-02-18T13:38:16.539707+00:00 app[api]: Release v1 created by user myemail@gmail.com
2020-02-18T13:39:28.000000+00:00 app[api]: Build started by user myemail@gmail.com
2020-02-18T13:39:29.000000+00:00 app[api]: Build failed -- check your build output: https://dashboard.heroku.com/apps/fdcfdeca-6786-4e3a-82b5-3ed6ee7a5517/activity/builds/b161fc9c-34f9-4258-8f6a-c8cf73016f74
2020-02-18T13:40:39.000000+00:00 app[api]: Build started by user myemail@gmail.com
2020-02-18T13:40:40.000000+00:00 app[api]: Build failed -- check your build output: https://dashboard.heroku.com/apps/fdcfdeca-6786-4e3a-82b5-3ed6ee7a5517/activity/builds/6a2ef41e-da40-4b22-9f44-dfc558e3f8c6
2020-02-18T13:41:55.000000+00:00 app[api]: Build started by user myemail@gmail.com
2020-02-18T13:41:56.000000+00:00 app[api]: Build failed -- check your build output: https://dashboard.heroku.com/apps/fdcfdeca-6786-4e3a-82b5-3ed6ee7a5517/activity/builds/7e98abc0-c073-40bd-bdcd-3e3c1960a1d4
2020-02-18T13:42:06.962017+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/" host=event-finder-au.herokuapp.com request_id=447e958f-de6c-40d4-bee4-8d3d61531a72 fwd="86.7.194.99" dyno= connect= service= status=502 bytes= protocol=https
2020-02-18T13:42:07.345863+00:00 heroku[router]: at=info code=H81 desc="Blank app" method=GET path="/favicon.ico" host=event-finder-au.herokuapp.com request_id=227ffbed-06eb-4120-8e6a-c8ceded83237 fwd="86.7.194.99" dyno= connect= service= status=502 bytes= protocol=https
2020-02-18T13:48:08.000000+00:00 app[api]: Build started by user myemail@gmail.com
2020-02-18T13:48:09.000000+00:00 app[api]: Build failed -- check your build output: https://dashboard.heroku.com/apps/fdcfdeca-6786-4e3a-82b5-3ed6ee7a5517/activity/builds/851460c8-5acc-4547-89b0-723b2cb0070b
2020-02-18T13:48:42.000000+00:00 app[api]: Build started by user myemail@gmail.com
2020-02-18T13:48:43.000000+00:00 app[api]: Build failed -- check your build output: https://dashboard.heroku.com/apps/fdcfdeca-6786-4e3a-82b5-3ed6ee7a5517/activity/builds/bb02d5f6-b034-476f-8855-ad5173bedfa4
2020-02-18T13:51:22.000000+00:00 app[api]: Build started by user myemail@gmail.com
2020-02-18T13:51:23.000000+00:00 app[api]: Build failed -- check your build output: https://dashboard.heroku.com/apps/fdcfdeca-6786-4e3a-82b5-3ed6ee7a5517/activity/builds/7c1b17e9-27b2-4169-9a6b-c33a7593a20d
2020-02-18T13:55:45.000000+00:00 app[api]: Build started by user myemail@gmail.com
2020-02-18T13:55:46.000000+00:00 app[api]: Build failed -- check your build output: https://dashboard.heroku.com/apps/fdcfdeca-6786-4e3a-82b5-3ed6ee7a5517/activity/builds/caf2422c-28bd-4362-9a00-40a1e8a4bef9
2020-02-18T13:56:58.000000+00:00 app[api]: Build started by user myemail@gmail.com
2020-02-18T13:56:59.000000+00:00 app[api]: Build failed -- check your build output: https://dashboard.heroku.com/apps/fdcfdeca-6786-4e3a-82b5-3ed6ee7a5517/activity/builds/44aabc7b-81a4-45c8-95ab-3ba0b0b98cb2
2020-02-18T13:59:22.000000+00:00 app[api]: Build started by user myemail@gmail.com
2020-02-18T13:59:24.000000+00:00 app[api]: Build failed -- check your build output: https://dashboard.heroku.com/apps/fdcfdeca-6786-4e3a-82b5-3ed6ee7a5517/activity/builds/6e917697-398f-46ca-89e7-a127db05608e
2020-02-18T14:00:58.000000+00:00 app[api]: Build started by user myemail@gmail.com
2020-02-18T14:01:00.000000+00:00 app[api]: Build failed -- check your build output: https://dashboard.heroku.com/apps/fdcfdeca-6786-4e3a-82b5-3ed6ee7a5517/activity/builds/bf2be350-233f-4320-ab4e-034b13bb6a9d
2020-02-18T14:01:19.000000+00:00 app[api]: Build started by user myemail@gmail.com
2020-02-18T14:01:20.000000+00:00 app[api]: Build failed -- check your build output: https://dashboard.heroku.com/apps/fdcfdeca-6786-4e3a-82b5-3ed6ee7a5517/activity/builds/42aba518-a40c-4f50-b4c5-839aecdeeb35
2020-02-18T14:02:44.000000+00:00 app[api]: Build started by user myemail@gmail.com
2020-02-18T14:03:40.379721+00:00 app[api]: Deploy 2daf4356 by user myemail@gmail.com
2020-02-18T14:03:40.379721+00:00 app[api]: Release v3 created by user myemail@gmail.com
2020-02-18T14:03:40.400674+00:00 app[api]: Scaled to web@1:Free by user myemail@gmail.com
2020-02-18T14:03:45.330569+00:00 heroku[web.1]: Starting process with command `npm start`
2020-02-18T14:03:45.000000+00:00 app[api]: Build succeeded
2020-02-18T14:03:50.190387+00:00 heroku[web.1]: State changed from starting to crashed
2020-02-18T14:03:50.195889+00:00 heroku[web.1]: State changed from crashed to starting
2020-02-18T14:03:50.173709+00:00 heroku[web.1]: Process exited with status 1
2020-02-18T14:03:50.033183+00:00 app[web.1]: npm ERR! missing script: start
2020-02-18T14:03:50.058454+00:00 app[web.1]: 
2020-02-18T14:03:50.058836+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-02-18T14:03:50.058991+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2020-02-18T14_03_50_034Z-debug.log
2020-02-18T14:03:53.954752+00:00 heroku[web.1]: Starting process with command `npm start`
2020-02-18T14:03:56.614988+00:00 heroku[web.1]: State changed from starting to crashed
2020-02-18T14:03:56.600007+00:00 heroku[web.1]: Process exited with status 1
2020-02-18T14:03:56.523382+00:00 app[web.1]: npm ERR! missing script: start
2020-02-18T14:03:56.536675+00:00 app[web.1]: 
2020-02-18T14:03:56.537274+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-02-18T14:03:56.537588+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2020-02-18T14_03_56_524Z-debug.log
2020-02-18T14:03:58.167610+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=event-finder-au.herokuapp.com request_id=6461804e-4804-4ce0-91b0-314ba1d0a0b4 fwd="86.7.194.99" dyno= connect= service= status=503 bytes= protocol=https
2020-02-18T14:03:58.671517+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=event-finder-au.herokuapp.com request_id=0072ed32-b9ad-4205-a3e0-111a4b57eb45 fwd="86.7.194.99" dyno= connect= service= status=503 bytes= protocol=https
2020-02-18T14:05:11.000000+00:00 app[api]: Build started by user myemail@gmail.com
2020-02-18T14:05:49.857750+00:00 heroku[web.1]: State changed from crashed to starting
2020-02-18T14:05:49.660236+00:00 app[api]: Deploy 6b00eac2 by user myemail@gmail.com
2020-02-18T14:05:49.660236+00:00 app[api]: Release v4 created by user myemail@gmail.com
2020-02-18T14:05:53.023230+00:00 heroku[web.1]: Starting process with command `npm start`
2020-02-18T14:05:55.615774+00:00 heroku[web.1]: State changed from starting to crashed
2020-02-18T14:05:55.540224+00:00 app[web.1]: npm ERR! missing script: start
2020-02-18T14:05:55.549366+00:00 app[web.1]: 
2020-02-18T14:05:55.549975+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-02-18T14:05:55.550306+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2020-02-18T14_05_55_541Z-debug.log
2020-02-18T14:05:55.602183+00:00 heroku[web.1]: Process exited with status 1
2020-02-18T14:05:54.000000+00:00 app[api]: Build succeeded
2020-02-18T14:06:01.546305+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=event-finder-au.herokuapp.com request_id=3bc8dfc5-a6f2-436f-bcf2-9fbb2dc54e5c fwd="86.7.194.99" dyno= connect= service= status=503 bytes= protocol=https
2020-02-18T14:06:01.850676+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=event-finder-au.herokuapp.com request_id=6736e715-66e8-4cc7-9425-6a1f45307230 fwd="86.7.194.99" dyno= connect= service= status=503 bytes= protocol=https

当涉及到这种事情时,我是一个完全的新手,所以我真的不知道这意味着什么。

如果有帮助,我的 package.json 看起来像这样 -

{
  "name": "basic-react-webpack-setup",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "serve": "webpack-dev-server --mode=development"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@babel/core": "^7.2.2",
    "@babel/preset-env": "^7.2.3",
    "@babel/preset-react": "^7.0.0",
    "babel-loader": "^8.0.5",
    "css-loader": "^2.1.0",
    "html-webpack-plugin": "^3.2.0",
    "node-sass": "^4.13.1",
    "sass-loader": "^7.1.0",
    "style-loader": "^0.23.1",
    "webpack": "^4.41.2",
    "webpack-cli": "^3.2.1",
    "webpack-dev-server": "^3.9.0"
  },
  "dependencies": {
    "axios": "^0.19.0",
    "bulma": "^0.8.0",
    "child_process": "^1.0.2",
    "cluster": "^0.7.7",
    "file": "^0.2.2",
    "lib": "^4.0.5",
    "loader": "^2.1.1",
    "moment": "^2.24.0",
    "react": "^16.12.0",
    "react-dom": "^16.12.0",
    "react-map-gl": "^5.1.3",
    "react-router-dom": "^5.1.2",
    "url": "^0.11.0"
  }
}

标签: node.jsreactjsherokunpm

解决方案


该输出的重要部分是:

npm ERR! missing script: start

Heroku 需要知道如何运行您的应用程序。您可以提供一个Procfile带有相关命令的命令,例如

web: node server.js

或者你可以添加一个start脚本到你的package.json,因为 Heroku 在没有Procfilefor JavaScript 项目的情况下默认运行它:

"scripts": {
  "test": "echo \"Error: no test specified\" && exit 1",
  "serve": "webpack-dev-server --mode=development",
  "start" "node server.js"
},

显然,您必须根据应用程序的工作方式调整命令。


推荐阅读