Heroku部署react(Node)应用程序时出错

我有麻烦部署反应的应用程序heroku。 我使用以下样板作为起点: https : //github.com/reactGo/reactGo ,但我将它与现有的应用程序相结合。 我在本地进行了testing,运行/构build正常,但是heroku给了我以下错误:

2017-05-10T21:43:07.399992+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch 2017-05-10T21:43:07.400522+00:00 heroku[web.1]: Stopping process with SIGKILL 2017-05-10T21:43:07.615526+00:00 heroku[web.1]: Process exited with status 137 2017-05-10T21:43:07.631086+00:00 heroku[web.1]: State changed from starting to crashed 2017-05-10T21:43:07.632321+00:00 heroku[web.1]: State changed from crashed to starting 2017-05-10T21:43:13.661987+00:00 heroku[web.1]: Starting process with command `npm start` 2017-05-10T21:43:16.475503+00:00 app[web.1]: 2017-05-10T21:43:16.475524+00:00 app[web.1]: > react-webpack-node@3.4.1 start /app 2017-05-10T21:43:16.475526+00:00 app[web.1]: > npm run build && cross-env NODE_ENV=production node compiled/server.js 2017-05-10T21:43:16.475526+00:00 app[web.1]: 2017-05-10T21:43:16.944768+00:00 app[web.1]: 2017-05-10T21:43:16.944783+00:00 app[web.1]: > react-webpack-node@3.4.1 build /app 2017-05-10T21:43:16.944787+00:00 app[web.1]: > npm run clean && cross-env NODE_ENV=production npm run webpack -- --env.browser && cross-env NODE_ENV=production npm run webpack -- --env.server 2017-05-10T21:43:16.944788+00:00 app[web.1]: 2017-05-10T21:43:17.328771+00:00 app[web.1]: 2017-05-10T21:43:17.328785+00:00 app[web.1]: > react-webpack-node@3.4.1 clean /app 2017-05-10T21:43:17.328786+00:00 app[web.1]: > rimraf public && rimraf compiled 2017-05-10T21:43:17.328787+00:00 app[web.1]: 2017-05-10T21:43:18.095069+00:00 app[web.1]: 2017-05-10T21:43:18.095084+00:00 app[web.1]: > react-webpack-node@3.4.1 webpack /app 2017-05-10T21:43:18.095085+00:00 app[web.1]: > webpack --colors --display-error-details --config ./webpack/webpack.config.js "--env.browser" 2017-05-10T21:43:18.095086+00:00 app[web.1]: 2017-05-10T21:43:18.812288+00:00 app[web.1]: Running webpack in production mode on browser 2017-05-10T21:43:35.602105+00:00 heroku[run.4255]: Process exited with status 130 2017-05-10T21:43:35.611860+00:00 heroku[run.4255]: State changed from up to complete 2017-05-10T21:43:59.732215+00:00 heroku[web.1]: Process running mem=543M(106.1%) 2017-05-10T21:43:59.732277+00:00 heroku[web.1]: Error R14 (Memory quota exceeded) 2017-05-10T21:44:13.716290+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch 2017-05-10T21:44:13.716376+00:00 heroku[web.1]: Stopping process with SIGKILL 2017-05-10T21:44:13.741192+00:00 app[web.1]: Error waiting for process to terminate: No child processes 2017-05-10T21:44:13.966647+00:00 heroku[web.1]: State changed from starting to crashed 2017-05-10T21:44:13.954005+00:00 heroku[web.1]: Process exited with status 22 2017-05-10T21:44:16.287420+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=boiling-spire-17544.herokuapp.com request_id=d4b52f95-a50e-4579-84a0-3b7411726415 fwd="24.207.50.90" dyno= connect= service= status=503 bytes= protocol=https 2017-05-10T21:44:24.777756+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=boiling-spire-17544.herokuapp.com request_id=1463bd52-de1d-4351-960d-aedf412c622a fwd="24.207.50.90" dyno= connect= service= status=503 bytes= protocol=https 2017-05-10T21:44:25.694845+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=boiling-spire-17544.herokuapp.com request_id=7735e9de-bc4d-4535-b06e-b004b9cc4c8b fwd="24.207.50.90" dyno= connect= service= status=503 bytes= protocol=https 2017-05-10T21:47:47.310866+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=boiling-spire-17544.herokuapp.com request_id=de042817-c34a-45e1-88ba-03eaeb78dd19 fwd="24.207.50.90" dyno= connect= service= status=503 bytes= protocol=https 2017-05-10T21:47:48.232781+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=boiling-spire-17544.herokuapp.com request_id=8edae68e-5bb8-444e-94e3-cffafb392b15 fwd="24.207.50.90" dyno= connect= service= status=503 bytes= protocol=https 

以下是我尝试失败的原因:-restarting heroku – validation端口是dynamic安装的

有什么build议么?

启动过程中出现R10错误:错误R10(引导超时) – > Web进程无法在启动后的60秒内绑定到$ PORT

您应该忘记将您的服务器绑定到名为PORT的环境variables。 你必须从ReactGo样板中find以下代码: app.set('port', (process.env.PORT || 3000)); 或更直截了当: app.listen(process.env.PORT || 3000);

要么

构build过程需要60多秒才能完成,导致您的测功机在您的应用程序被构build之前终止。 您需要使用专门的CI工具(如提供连接到Heroku的CircleCI)来构build应用程序,然后在heroku上启动它。

Heroku中的R14不是严重错误,但会降低性能。 如果你使用Heroku作为一个持续集成平台(就像我在日志中看到的那样),这可能在构build期间很容易发生。

您正在收到“错误R14(超出内存配额)”。 检查R14 – 内存配额超过看到一些可能的提示。 也许你已经把太多的function包装在一个测功机里了? 你的Procfile是什么样的,你用的是什么types的dyno?