Heroku部署应用程序崩溃,代码错误代码为= H10

时间:2019-03-06 18:56:29

标签: node.js heroku

我是heroku的新手,并且已经在其中部署了节点应用程序。当我使用webpack进行编译时,我在本地的应用程序运行良好,但是当我在Heroku中进行部署时,我得到的代码错误代码为= H10。我重新启动了所有测功机,并且得到了以下日志:

2019-03-06T18:37:21.181303+00:00 app[web.1]: Version: webpack 4.29.4

2019-03-06T18:37:21.181305+00:00 app[web.1]: Time: 6053ms

2019-03-06T18:37:21.181306+00:00 app[web.1]: Built at: 03/06/2019 6:37:21 PM

2019-03-06T18:37:21.181309+00:00 app[web.1]:                                Asset      Size  Chunks                    Chunk Names

2019-03-06T18:37:21.181312+00:00 app[web.1]: 0a1ce4bd2f68c46725730d10762f050f.ttf  57.1 KiB          [emitted]         

2019-03-06T18:37:21.181313+00:00 app[web.1]: 575e4317521b381ac94c0c8207c81979.ttf   175 KiB          [emitted]         

2019-03-06T18:37:21.181315+00:00 app[web.1]: 580d0778ad254335be45bf58bb449f43.ttf   174 KiB          [emitted]         

2019-03-06T18:37:21.181316+00:00 app[web.1]: a2c977bb9c9811e1b0e3eee168fbd913.ttf  56.3 KiB          [emitted]         

2019-03-06T18:37:21.181317+00:00 app[web.1]: dc466c6319df694a72360d9601596ef9.ttf  54.8 KiB          [emitted]         

2019-03-06T18:37:21.181319+00:00 app[web.1]:                           index.html  1.42 KiB          [emitted]         

2019-03-06T18:37:21.181320+00:00 app[web.1]:                         js/bundle.js  2.22 MiB       0  [emitted]  [big]  app

2019-03-06T18:37:21.181321+00:00 app[web.1]: Entrypoint app [big] = js/bundle.js

2019-03-06T18:37:21.181323+00:00 app[web.1]:  [24] ./node_modules/react-bootstrap/es/index.js + 96 modules 182 KiB {0} [built]

2019-03-06T18:37:21.181324+00:00 app[web.1]:       |    97 modules

2019-03-06T18:37:21.181326+00:00 app[web.1]:  [69] ./src/client/index.js 468 bytes {0} [built]

2019-03-06T18:37:21.181328+00:00 app[web.1]:  [74] ./src/client/App.js 3.62 KiB {0} [built]

2019-03-06T18:37:21.181329+00:00 app[web.1]:  [75] ./src/client/App.css 1.06 KiB {0} [built]

2019-03-06T18:37:21.181331+00:00 app[web.1]:  [76] ./node_modules/css-loader/dist/cjs.js!./src/client/App.css 174 bytes {0} [built]

2019-03-06T18:37:21.181332+00:00 app[web.1]:  [79] ./src/client/css/header.css 1.08 KiB {0} [built]

2019-03-06T18:37:21.181333+00:00 app[web.1]:  [80] ./node_modules/css-loader/dist/cjs.js!./src/client/css/header.css 295 bytes {0} [built]

2019-03-06T18:37:21.181335+00:00 app[web.1]:  [81] ./src/client/img/logo-basketmetrics-pink.png 12 KiB {0} [built]

2019-03-06T18:37:21.181336+00:00 app[web.1]:  [83] ./src/client/css/content.css 1.08 KiB {0} [built]

2019-03-06T18:37:21.181338+00:00 app[web.1]:  [84] ./node_modules/css-loader/dist/cjs.js!./src/client/css/content.css 1.56 KiB {0} [built]

2019-03-06T18:37:21.181339+00:00 app[web.1]: [130] ./src/client/css/tabscontrolled.css 1.11 KiB {0} [built]

2019-03-06T18:37:21.181340+00:00 app[web.1]: [144] ./src/client/css/footer.css 1.08 KiB {0} [built]

2019-03-06T18:37:21.181342+00:00 app[web.1]: [145] ./node_modules/css-loader/dist/cjs.js!./src/client/css/footer.css 484 bytes {0} [built]

2019-03-06T18:37:21.181343+00:00 app[web.1]: [146] ./src/client/index.css 1.07 KiB {0} [built]

2019-03-06T18:37:21.181344+00:00 app[web.1]: [147] ./node_modules/css-loader/dist/cjs.js!./src/client/index.css 201 bytes {0} [built]

2019-03-06T18:37:21.181345+00:00 app[web.1]:     + 135 hidden modules

2019-03-06T18:37:21.181347+00:00 app[web.1]: 

2019-03-06T18:37:21.181348+00:00 app[web.1]: WARNING in configuration

2019-03-06T18:37:21.181353+00:00 app[web.1]: The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment.

2019-03-06T18:37:21.181355+00:00 app[web.1]: You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/concepts/mode/

2019-03-06T18:37:21.181356+00:00 app[web.1]: 

2019-03-06T18:37:21.181359+00:00 app[web.1]: WARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).

2019-03-06T18:37:21.181360+00:00 app[web.1]: This can impact web performance.

2019-03-06T18:37:21.181361+00:00 app[web.1]: Assets: 

2019-03-06T18:37:21.181362+00:00 app[web.1]:   js/bundle.js (2.22 MiB)

2019-03-06T18:37:21.181364+00:00 app[web.1]: 

2019-03-06T18:37:21.181365+00:00 app[web.1]: WARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.

2019-03-06T18:37:21.181367+00:00 app[web.1]: Entrypoints:

2019-03-06T18:37:21.181368+00:00 app[web.1]:   app (2.22 MiB)

2019-03-06T18:37:21.181369+00:00 app[web.1]:       js/bundle.js

2019-03-06T18:37:21.181371+00:00 app[web.1]: 

2019-03-06T18:37:21.181372+00:00 app[web.1]: 

2019-03-06T18:37:21.181373+00:00 app[web.1]: WARNING in webpack performance recommendations: 

2019-03-06T18:37:21.181375+00:00 app[web.1]: You can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application.

2019-03-06T18:37:21.181376+00:00 app[web.1]: For more info visit https://webpack.js.org/guides/code-splitting/

2019-03-06T18:37:21.181377+00:00 app[web.1]: Child html-webpack-plugin for "index.html":

2019-03-06T18:37:21.181379+00:00 app[web.1]:      1 asset

2019-03-06T18:37:21.181380+00:00 app[web.1]:     Entrypoint undefined = index.html

2019-03-06T18:37:21.181381+00:00 app[web.1]:     [0] ./node_modules/html-webpack-plugin/lib/loader.js!./src/client/index.html 1.77 KiB {0} [built]

2019-03-06T18:37:21.181383+00:00 app[web.1]:     [2] (webpack)/buildin/global.js 472 bytes {0} [built]

2019-03-06T18:37:21.181384+00:00 app[web.1]:     [3] (webpack)/buildin/module.js 497 bytes {0} [built]

2019-03-06T18:37:21.181385+00:00 app[web.1]:         + 1 hidden module

2019-03-06T18:37:21.571282+00:00 app[web.1]: webpack-internal:///17:23

2019-03-06T18:37:21.571295+00:00 app[web.1]:    return window && document && document.all && !window.atob;

2019-03-06T18:37:21.571297+00:00 app[web.1]:    ^

2019-03-06T18:37:21.571298+00:00 app[web.1]: 

2019-03-06T18:37:21.571302+00:00 app[web.1]: ReferenceError: window is not defined

2019-03-06T18:37:21.571304+00:00 app[web.1]:     at eval (webpack-internal:///17:23:2)

2019-03-06T18:37:21.571305+00:00 app[web.1]:     at eval (webpack-internal:///17:12:46)

2019-03-06T18:37:21.571307+00:00 app[web.1]:     at module.exports (webpack-internal:///17:80:88)

2019-03-06T18:37:21.571308+00:00 app[web.1]:     at eval (webpack-internal:///75:16:37)

2019-03-06T18:37:21.571310+00:00 app[web.1]:     at Object.<anonymous> (/app/build/js/bundle.js:1:1559274)

2019-03-06T18:37:21.571311+00:00 app[web.1]:     at n (/app/build/js/bundle.js:1:172)

2019-03-06T18:37:21.571312+00:00 app[web.1]:     at eval (webpack-internal:///74:10:1)

2019-03-06T18:37:21.571314+00:00 app[web.1]:     at Object.<anonymous> (/app/build/js/bundle.js:1:1554143)

2019-03-06T18:37:21.571315+00:00 app[web.1]:     at n (/app/build/js/bundle.js:1:172)

2019-03-06T18:37:21.571317+00:00 app[web.1]:     at eval (webpack-internal:///69:7:35)

2019-03-06T18:37:21.583851+00:00 app[web.1]: npm ERR! code ELIFECYCLE

2019-03-06T18:37:21.584546+00:00 app[web.1]: npm ERR! errno 1

2019-03-06T18:37:21.586811+00:00 app[web.1]: npm ERR! basketmetrics2@1.0.0 start: `npm run build && node ./build/js/bundle.js`

2019-03-06T18:37:21.587053+00:00 app[web.1]: npm ERR! Exit status 1

2019-03-06T18:37:21.588420+00:00 app[web.1]: npm ERR! 

2019-03-06T18:37:21.588700+00:00 app[web.1]: npm ERR! Failed at the basketmetrics2@1.0.0 start script.

2019-03-06T18:37:21.588933+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

2019-03-06T18:37:21.597607+00:00 app[web.1]: 

2019-03-06T18:37:21.597818+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:

2019-03-06T18:37:21.597910+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2019-03-06T18_37_21_591Z-debug.log

2019-03-06T18:37:21.671027+00:00 heroku[web.1]: State changed from starting to crashed

2019-03-06T18:37:21.654302+00:00 heroku[web.1]: Process exited with status 1

2019-03-06T18:38:09.247225+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=basketmetrics.herokuapp.com request_id=d1cc983f-43a0-402f-ab34-1301614c9e74 fwd="84.120.148.240" dyno= connect= service= status=503 bytes= protocol=https

我已经搜索了可能导致错误的原因,并且已经正确定义了端口和主机。

这是我定义服务器端口和主机时的代码:

//Settings
app.set("port", process.env.PORT || 3000);
app.set("host", "0.0.0.0");
//Start server
app.listen(app.get("port"), app.get("host"), () => {
    console.log("Server running on port: ", app.get("port"));
})

因此,我不知道我在做什么错。

编辑我:

package.json:

{
  "name": "basketmetrics2",
  "version": "1.0.0",
  "description": "Basketball advanced stats",
  "engines": {
    "node": "10.12.0",
    "npm": "6.4.1"
  },
  "main": "index.js",
  "scripts": {
    "dev": "nodemon --exec babel-node src/server/server.js",
    "test": "echo \"Error: no test specified\" && exit 1",
    "build": "npm run clean && npm run compile",
    "clean": "rm -rf ./build",
    "compile": "NODE_ENV=production webpack --config ./webpack.config.babel.js --progress",
    "start": "npm run build && node ./build/js/bundle.js",
    "heroku-postbuild": "webpack -p"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@babel/cli": "^7.2.3",
    "@babel/core": "^7.3.3",
    "@babel/node": "^7.2.2",
    "@babel/preset-env": "^7.3.1",
    "@babel/preset-react": "^7.0.0",
    "babel-loader": "^8.0.5",
    "babel-plugin-transform-class-properties": "^6.24.1",
    "css-loader": "^2.1.0",
    "file-loader": "^3.0.1",
    "html-webpack-plugin": "^3.2.0",
    "node-sass": "^4.11.0",
    "nodemon": "^1.18.10",
    "sass-loader": "^7.1.0",
    "style-loader": "^0.23.1",
    "url-loader": "^1.1.2",
    "webpack": "^4.29.4",
    "webpack-cli": "^3.2.3",
    "webpack-dev-middleware": "^3.5.2",
    "webpack-dev-server": "^3.2.1",
    "webpack-livereload-plugin": "^2.2.0"
  },
  "dependencies": {
    "bootstrap": "^4.3.1",
    "express": "^4.16.4",
    "jquery": "^3.3.1",
    "popper.js": "^1.14.7",
    "react": "^16.8.2",
    "react-bootstrap": "^1.0.0-beta.5",
    "react-dom": "^16.8.2"
  }
}

index.html

<!DOCTYPE html>
<html lang = "es">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>
            Basketmetrics: Estadísticas avanzadas de baloncesto femenino - Advanced stats female basketball
        </title>
        <meta name="viewport" content="width=device-width, initial-scale=1">   
    </head>
    <body>
        <div id = "root"></div>
    </body>
</html>

0 个答案:

没有答案