首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >使用react和Node部署到Herolu时出现问题

使用react和Node部署到Herolu时出现问题
EN

Stack Overflow用户
提问于 2018-09-14 04:04:38
回答 1查看 235关注 0票数 0

我设法使用react、node和graphQL成功地构建了heroku,但在浏览器中看不到应用程序。当我运行"heroku logs --tail“时,我得到...

代码语言:javascript
复制
State changed from crashed to starting
2018-09-13T19:44:49.433722+00:00 heroku[web.1]: Starting process with command `npm start`
2018-09-13T19:44:53.370636+00:00 app[web.1]:
2018-09-13T19:44:53.370683+00:00 app[web.1]: > Workout_JS@1.0.0 start /app
2018-09-13T19:44:53.370685+00:00 app[web.1]: > concurrently "cd client && PORT=3000 npm start" "cd server && PORT=5000 npm app.js"
2018-09-13T19:44:53.370687+00:00 app[web.1]:
2018-09-13T19:44:57.077898+00:00 app[web.1]: [1]
2018-09-13T19:44:57.077919+00:00 app[web.1]: [1] Usage: npm <command>
2018-09-13T19:44:57.077921+00:00 app[web.1]: [1]
2018-09-13T19:44:57.077922+00:00 app[web.1]: [1] where <command> is one of:
2018-09-13T19:44:57.077927+00:00 app[web.1]: [1]     access, adduser, bin, bugs, c, cache, completion, config,
2018-09-13T19:44:57.077930+00:00 app[web.1]: [1]     ddp, dedupe, deprecate, dist-tag, docs, doctor, edit,
2018-09-13T19:44:57.077932+00:00 app[web.1]: [1]     explore, get, help, help-search, i, init, install,
2018-09-13T19:44:57.077933+00:00 app[web.1]: [1]     install-test, it, link, list, ln, login, logout, ls,
2018-09-13T19:44:57.077934+00:00 app[web.1]: [1]     outdated, owner, pack, ping, prefix, prune, publish, rb,
2018-09-13T19:44:57.077936+00:00 app[web.1]: [1]     rebuild, repo, restart, root, run, run-script, s, se,
2018-09-13T19:44:57.077938+00:00 app[web.1]: [1]     search, set, shrinkwrap, star, stars, start, stop, t, team,
2018-09-13T19:44:57.077939+00:00 app[web.1]: [1]     test, tst, un, uninstall, unpublish, unstar, up, update,v,
2018-09-13T19:44:57.077940+00:00 app[web.1]: [1]     version, view, whoami
2018-09-13T19:44:57.077943+00:00 app[web.1]: [1] npm <command> -h     quick help on <command>
2018-09-13T19:44:57.077942+00:00 app[web.1]: [1]
2018-09-13T19:44:57.077946+00:00 app[web.1]: [1] npm -l           display full usage info
2018-09-13T19:44:57.077947+00:00 app[web.1]: [1] npm help <term>  search for help on <term>
2018-09-13T19:44:57.077949+00:00 app[web.1]: [1] npm help npm     involved overview
2018-09-13T19:44:57.077951+00:00 app[web.1]: [1]
2018-09-13T19:44:57.077952+00:00 app[web.1]: [1] Specify configs in the ini-formatted file:
2018-09-13T19:44:57.077953+00:00 app[web.1]: [1]     /app/.npmrc
2018-09-13T19:44:57.077955+00:00 app[web.1]: [1] or on the command line via: npm <command> --key value
2018-09-13T19:44:57.077956+00:00 app[web.1]: [1] Config info can be viewed via: npm help config
2018-09-13T19:44:57.077958+00:00 app[web.1]: [1]
2018-09-13T19:44:57.077959+00:00 app[web.1]: [1] npm@5.3.0 /app/.heroku/node/lib/node_modules/npm
2018-09-13T19:44:57.095023+00:00 app[web.1]: [1] cd server && PORT=5000 npm app.js exited with code 1
2018-09-13T19:44:57.330192+00:00 app[web.1]: [0]
2018-09-13T19:44:57.330203+00:00 app[web.1]: [0] > client@0.1.0 start /app/client
2018-09-13T19:44:57.330205+00:00 app[web.1]: [0] > react-scripts start
2018-09-13T19:44:57.330207+00:00 app[web.1]: [0]
2018-09-13T19:45:04.225951+00:00 app[web.1]: [0] Starting the development server...
2018-09-13T19:45:04.225966+00:00 app[web.1]: [0]
2018-09-13T19:45:29.117989+00:00 app[web.1]: [0] Compiled with warnings.
2018-09-13T19:45:29.118003+00:00 app[web.1]: [0]
2018-09-13T19:45:29.118005+00:00 app[web.1]: [0] ./src/components/Modal.js
2018-09-13T19:45:29.118007+00:00 app[web.1]: [0]   Line 11:  Unreachable code  no-unreachable
2018-09-13T19:45:29.118009+00:00 app[web.1]: [0]   Line 14:  Unreachable code  no-unreachable
2018-09-13T19:45:29.118011+00:00 app[web.1]: [0]
2018-09-13T19:45:29.118013+00:00 app[web.1]: [0] ./src/components/Timer.js
2018-09-13T19:45:29.118016+00:00 app[web.1]: [0]
2018-09-13T19:45:29.118015+00:00 app[web.1]: [0]   Line 30:  'run' is assigned a value but never used  no-unused-vars
2018-09-13T19:45:29.118020+00:00 app[web.1]: [0]   Line 40:  'movements' is assigned a value but never used  no-unused-vars
2018-09-13T19:45:29.118018+00:00 app[web.1]: [0] ./src/components/Push.js
2018-09-13T19:45:29.118022+00:00 app[web.1]: [0]
2018-09-13T19:45:29.118023+00:00 app[web.1]: [0] ./src/components/Length.js
2018-09-13T19:45:29.118025+00:00 app[web.1]: [0]   Line 47:  Expected to return a value in arrow function    array-callback-return
2018-09-13T19:45:29.118029+00:00 app[web.1]: [0]   Line 54:  'movements' is assigned a value but never used  no-unused-vars
2018-09-13T19:45:29.118036+00:00 app[web.1]: [0]
2018-09-13T19:45:29.118030+00:00 app[web.1]: [0]
2018-09-13T19:45:29.118027+00:00 app[web.1]: [0]   Line 53:  'wods' is assigned a value but never used       no-unused-vars
2018-09-13T19:45:29.118034+00:00 app[web.1]: [0] To ignore, add // eslint-disable-next-line to the line before.
2018-09-13T19:45:29.118032+00:00 app[web.1]: [0] Search for the keywords to learn more about each warning.
2018-09-13T19:45:34.000000+00:00 app[api]: Build started by user brad.hankee@gmail.com
2018-09-13T19:45:50.123072+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2018-09-13T19:45:50.123205+00:00 heroku[web.1]: Stopping process with SIGKILL
2018-09-13T19:45:50.297808+00:00 heroku[web.1]: State changed from starting to crashed
2018-09-13T19:45:50.282015+00:00 heroku[web.1]: Process exited with status 137
2018-09-13T19:46:40.674676+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=workout-js.herokuapp.com request_id=fea7a8cf-f60f-47dc-9d8f-e3a6447de8b1 fwd="98.166.56.134" dyno= connect= service= status=503 bytes= protocol=https
2018-09-13T19:46:40.879839+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=workout-js.herokuapp.com request_id=00bd54f8-ccfa-410a-9719-36adfcca38b8 fwd="98.166.56.134" dyno= connect= service= status=503 bytes= protocol=https
2018-09-13T19:46:42.370752+00:00 app[api]: Deploy daef049a by user brad.hankee@gmail.com
2018-09-13T19:46:42.370752+00:00 app[api]: Release v6 created by user brad.hankee@gmail.com
2018-09-13T19:46:43.950807+00:00 heroku[web.1]: State changed from crashed to starting
2018-09-13T19:46:43.000000+00:00 app[api]: Build succeeded
2018-09-13T19:46:51.564733+00:00 heroku[web.1]: Starting process with command `npm start`
2018-09-13T19:46:54.322782+00:00 heroku[web.1]: State changed from starting to crashed
2018-09-13T19:46:54.244449+00:00 app[web.1]:
2018-09-13T19:46:54.244488+00:00 app[web.1]: > Workout_JS@1.0.0 start /app
2018-09-13T19:46:54.244490+00:00 app[web.1]: > cd server npm app.js
2018-09-13T19:46:54.244492+00:00 app[web.1]:
2018-09-13T19:46:54.304960+00:00 heroku[web.1]: Process exited with status 0

在dev中使用并发运行,但不确定如何为heroku设置脚本...我的文件结构是...

app -client -- package.json -server -- package.json package.json

下面是我详细介绍的三个package.jsons:

客户端

代码语言:javascript
复制
{
  "name": "client",
  "version": "0.1.0",
  "engines": {
    "node": "8.2.0"
  },
  "proxy": "http://localhost:5000",
  "private": true,
  "dependencies": {
    "@reach/router": "^1.1.1",
    "apollo-boost": "^0.1.14",
    "graphql": "^0.13.2",
    "react": "^16.4.2",
    "react-apollo": "^2.1.11",
    "react-dom": "^16.4.2",
    "react-scripts": "1.1.5",
    "react-transition-group": "^2.4.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

服务器

代码语言:javascript
复制
{
  "name": "server",
  "version": "1.0.0",
  "engines": {
    "node": "8.2.0"
  },
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node app.js"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "cors": "^2.8.4",
    "dotenv": "^6.0.0",
    "express": "^4.16.3",
    "express-graphql": "^0.6.12",
    "graphql": "^0.13.2",
    "lodash": "^4.17.10",
    "mongoose": "^5.2.9"
  }
}

根部

代码语言:javascript
复制
{
  "name": "Workout_JS",
  "version": "1.0.0",
  "engines": {
    "node": "8.2.0"
  },
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "cd server npm app.js",
    "heroku-postbuild": "cd client && npm install && npm run build"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/bhankee/Workout.js.git"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/bhankee/Workout.js/issues"
  },
  "homepage": "https://github.com/bhankee/Workout.js#readme",
  "dependencies": {
    "concurrently": "^4.0.1"
  }
}

也谢谢,我确实用了这是根程序包.json,但没有用到

代码语言:javascript
复制
"start": "concurrently \"cd client && PORT=3000 npm start\" \"cd server && PORT=5000 npm app.js\"",
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-09-14 08:15:29

您必须将您的应用程序绑定到$PORT。现在,您似乎绑定到了5000。因此,您会得到以下错误:

2018-09-13T19:45:50.123072+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

这里有更多信息:https://help.heroku.com/P1AVPANS/why-is-my-node-js-app-crashing-with-an-r10-error

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52321047

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档