错误R10(启动超时)-> Web进程在package.json中启动后60秒内未能绑定到$ PORT

时间:2020-03-09 15:18:23

标签: heroku

[34mℹ[39m [90m「wds」[39m: Project is running at http://localhost:47627/
2020-03-09T15:02:19.370628+00:00 app[web.1]: [34mℹ[39m [90m「wds」[39m: webpack output is served from /
2020-03-09T15:02:19.370747+00:00 app[web.1]: [34mℹ[39m [90m「wds」[39m: Content not from webpack is served from /app
2020-03-09T15:02:24.227741+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2020-03-09T15:02:24.227741+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-03-09T15:02:24.454880+00:00 heroku[web.1]: State changed from starting to crashed
2020-03-09T15:02:24.434525+00:00 heroku[web.1]: Process exited with status 137
    "heroku-dev": "npm i -dev",
    "wbuild": "webpack --mode production",
    "wstart": "webpack-dev-server --mode development --hot --open --port $PORT",

web:npm运行heroku-dev && npm运行wbuild && npm运行wstart

Idk, i looked around the internet, but couldn't find anything

2 个答案:

答案 0 :(得分:0)

https://devcenter.heroku.com/articles/app-json-schema

在您的app.json中,您需要一个postdeploy脚本。

我认为这是您当前的Procfile

web: npm run heroku-dev && npm run wbuild && npm run wstart

将其更改为:

web: npm run wstart

您的postdeploy应该说npm run heroku-dev && npm run wbuild


第二种方法是通过package.json(不需要app.json)进行操作。
它的工作方式与此类似,请参见此处的文档:

https://devcenter.heroku.com/articles/nodejs-support#customizing-the-build-process

"scripts": {
  "start": "webpack-dev-server --mode development --hot --open --port $PORT",
  "build": "npm i -dev && webpack --mode production",
  "heroku-postbuild": "npm build"
}

Procfileweb: npm start


您遇到的问题是,每次启动时都在构建项目,而绑定到$PORT的时间过长。部署后一开始就应该构建一次。

答案 1 :(得分:0)

我也遇到了同样的问题。经过调试发现—— 我错过了将应用绑定到 'process.env.PORT'

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