使用Heroku部署MEAN应用时出现奇怪的错误

时间:2018-12-21 16:14:06

标签: node.js heroku mean

我正在尝试使用Heroku部署我的MEAN应用。 这是构建日志,看起来很好:

-----> Node.js app detected

-----> Creating runtime environment

       NPM_CONFIG_LOGLEVEL=error
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       NODE_VERBOSE=false

-----> Installing binaries
       engines.node (package.json):  unspecified
       engines.npm (package.json):   unspecified (use default)

       Resolving node version 10.x...
       Downloading and installing node 10.14.2...
       Using default npm version: 6.4.1

-----> Restoring cache
       - node_modules

-----> Building dependencies
       Installing node modules (package.json + package-lock)

       > web-ra@0.0.0 postinstall /tmp/build_9a451d090ad89671a8d70d5e174464a1
       > ng build --aot -prod

       Date: 2018-12-21T15:47:51.322Z
       Hash: dbbdf40ebe489e9d578b
       Time: 108258ms
       chunk {scripts} scripts.c85cbcafd5073532702e.bundle.js (scripts) 137 kB [initial] [rendered]
       chunk {0} main.a62a079af1ac00241597.bundle.js (main) 1.68 MB [initial] [rendered]
       chunk {1} polyfills.194f3db5c95bb635c66b.bundle.js (polyfills) 59.7 kB [initial] [rendered]
       chunk {2} styles.3b21735590365920f879.bundle.css (styles) 189 kB [initial] [rendered]
       chunk {3} inline.318b50c57b4eba3d437b.bundle.js (inline) 796 bytes [entry] [rendered]
       audited 12952 packages in 127.206s
       found 41 vulnerabilities (12 low, 19 moderate, 10 high)
         run `npm audit fix` to fix them, or `npm audit` for details

-----> Caching build
       - node_modules

-----> Pruning devDependencies
       audited 12952 packages in 13.462s
       found 41 vulnerabilities (12 low, 19 moderate, 10 high)
         run `npm audit fix` to fix them, or `npm audit` for details

-----> Build succeeded!
-----> Discovering process types
       Procfile declares types     -> (none)
       Default types for buildpack -> web
-----> Compressing...
       Done: 95.5M
-----> Launching...
       Released v8
       https://web.herokuapp.com/ deployed to Heroku

但是在'heroku logs --tail'命令的帮助下,我得到了该日志,但是我不知道如何正确部署我的应用程序。它说明了有关内存的一些信息:

2018-12-21T02:41:13.833985+00:00 heroku[web.1]: Process running mem=583M(113.9%)
2018-12-21T02:41:13.834211+00:00 heroku[web.1]: Error R14 (Memory quota exceeded)
2018-12-21T08:25:57.924399+00:00 heroku[web.1]: State changed from crashed to starting
2018-12-21T08:26:08.734626+00:00 heroku[web.1]: Starting process with command `npm start`
2018-12-21T08:26:11.525782+00:00 app[web.1]:
2018-12-21T08:26:11.525805+00:00 app[web.1]: > web-ra@0.0.0 start /app
2018-12-21T08:26:11.525806+00:00 app[web.1]: > ng serve
2018-12-21T08:26:11.525808+00:00 app[web.1]:
2018-12-21T08:26:41.043684+00:00 app[web.1]: Date: 2018-12-21T08:26:41.042Z
2018-12-21T08:26:41.043697+00:00 app[web.1]: Hash: f0f974dce9d9bba2fce5
2018-12-21T08:26:41.043699+00:00 app[web.1]: Time: 24724ms
2018-12-21T08:26:41.043702+00:00 app[web.1]: chunk {inline} inline.bundle.js (inline) 3.85 kB [entry] [rendered]
2018-12-21T08:26:41.043704+00:00 app[web.1]: chunk {main} main.bundle.js (main) 634 kB [initial] [rendered]
2018-12-21T08:26:41.043716+00:00 app[web.1]: chunk {polyfills} polyfills.bundle.js (polyfills) 554 kB [initial] [rendered]
2018-12-21T08:26:41.043717+00:00 app[web.1]: chunk {scripts} scripts.bundle.js (scripts) 138 kB [initial] [rendered]
2018-12-21T08:26:41.043719+00:00 app[web.1]: chunk {styles} styles.bundle.js (styles) 556 kB [initial] [rendered]
2018-12-21T08:26:41.043721+00:00 app[web.1]: chunk {vendor} vendor.bundle.js (vendor) 20.4 MB [initial] [rendered]
2018-12-21T08:26:41.147505+00:00 app[web.1]:
2018-12-21T08:26:41.147628+00:00 app[web.1]: webpack: Compiled successfully.
2018-12-21T08:26:53.594326+00:00 heroku[web.1]: Process running mem=586M(114.5%)
2018-12-21T08:26:53.594422+00:00 heroku[web.1]: Error R14 (Memory quota exceeded)
2018-12-21T08:27:09.030536+00:00 heroku[web.1]: State changed from starting to crashed
2018-12-21T08:27:09.014687+00:00 heroku[web.1]: Process exited with status 137
2018-12-21T14:02:19.705614+00:00 heroku[web.1]: State changed from crashed to starting
2018-12-21T14:02:31.665748+00:00 heroku[web.1]: Starting process with command `npm start`
2018-12-21T14:02:34.930213+00:00 app[web.1]:
2018-12-21T14:02:34.930236+00:00 app[web.1]: > web-ra@0.0.0 start /app
2018-12-21T14:02:34.930238+00:00 app[web.1]: > ng serve
2018-12-21T14:02:34.930239+00:00 app[web.1]:
2018-12-21T14:02:39.839546+00:00 app[web.1]: ** NG Live Development Server is listening on localhost:15887, open your browser on http://localhost:198587/ **
2018-12-21T14:03:11.329430+00:00 heroku[web.1]: Process running mem=583M(113.9%)
2018-12-21T14:03:11.329430+00:00 heroku[web.1]: Error R14 (Memory quota exceeded)
2018-12-21T14:03:31.103066+00:00 heroku[web.1]: Process running mem=583M(113.9%)
2018-12-21T14:03:31.103185+00:00 heroku[web.1]: Error R14 (Memory quota exceeded)
2018-12-21T14:03:32.157338+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2018-12-21T14:03:32.157524+00:00 heroku[web.1]: Stopping process with SIGKILL
2018-12-21T14:03:32.185617+00:00 app[web.1]: Error waiting for process to terminate: No child processes
2018-12-21T14:03:32.289337+00:00 heroku[web.1]: Process exited with status 22
2018-12-21T15:31:23.535187+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=vast-garden-42795.herokuapp.com request_id=1cb86561-a3c1-49a0-b6f6-150efc246a7a fwd="84.77.253.96" dyno= connect= service= status=503 bytes= protocol=https

您能帮我解决这个问题吗?

谢谢!

1 个答案:

答案 0 :(得分:0)

由于错误,您的应用消耗的内存超过了免费层dyno(512 MB)分配的内存(RAM)。请参阅here了解Heroku测功机限制。

您剩下2个选择。

  • 升级您的dyno计划以拥有更大的内存。
  • 优化您的应用程序,以降低内存消耗。