为什么我不能成功将我的nodejs应用程序部署到heroku?

时间:2016-10-29 16:01:57

标签: javascript git reactjs heroku web-deployment

这是我第一次部署到heroku。部署本身是成功的,但当我打开应用程序时,我得到一个错误 看起来问题存在于package.json或Procfile中。 修复对你们来说可能很明显,但我是heroku的新手,所以不要生气 [编辑]我已通过运行heroku config:set NPM_CONFIG_PRODUCTION=false禁用了生产模式,但错误仍然只是日志已被更改 在此先感谢您的帮助! 详情如下:
app - https://evening-retreat-75182.herokuapp.com
github repo - https://github.com/dagman/Recipebook

Procfile

web: npm run start:production

的package.json

{
  "name": "Recipebook",
  "version": "1.0.0",
  "description": "The most kickass app for your cooking recipes",
  "main": "index.js",
  "engines": {
    "node": ">=5.0 <7",
    "npm": ">=3.0 <4"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/dagman/Recipebook.git"
  },
  "keywords": [
    "recipe",
    "recipes",
    "recipebook"
  ],
  "author": "Islam Ibakaev <islamibakaev@gmail.com> (https://github.com/dagman)",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/dagman/Recipebook/issues"
  },
  "homepage": "https://github.com/dagman/Recipebook",
  "scripts": {
    "start": "better-npm-run start",
    "start:production": "npm run build && npm run start:prod",
    "start:prod": "better-npm-run start:prod",
    "build": "npm run clean:build && better-npm-run build",
    "lint": "npm run lint:js && npm run lint:style",
    "lint:js": "better-npm-run lint:js",
    "lint:style": "better-npm-run lint:style",
    "test": "better-npm-run test",
    "test:watch": "npm test -- --no-single-run",
    "clean:all": "npm run clean:build && npm run clean:coverage",
    "clean:build": "better-npm-run clean:build",
    "clean:coverage": "better-npm-run clean:coverage",
    "coveralls": "better-npm-run coveralls && npm run test:clean"
  },
  "betterScripts": {
    "start": {
      "command": "nodemon ./index.js",
      "env": {
        "NODE_PATH": "./src",
        "NODE_ENV": "development",
        "PORT": "3000"
      }
    },
    "start:prod": {
      "command": "node ./index.js",
      "env": {
        "NODE_PATH": "./src",
        "NODE_ENV": "production",
        "PORT": "8080"
      }
    },
    "build": {
      "command": "webpack --progress --display-error-details --config ./tools/webpack/config.babel",
      "env": {
        "NODE_ENV": "production",
        "BABEL_ENV": "es"
      }
    },
    "lint:js": {
      "command": "eslint -c .eslintrc ./src ./tools ./index.js"
    },
    "lint:style": {
      "command": "stylelint \"./src/**/*.css\""
    },
    "test": {
      "command": "karma start ./tools/testing/karma.conf.js --single-run",
      "env": {
        "NODE_ENV": "test"
      }
    },
    "clean:build": {
      "command": "rimraf ./public/dist"
    },
    "clean:coverage": {
      "command": "rimraf ./coverage"
    },
    "coveralls": {
      "command": "cat ./coverage/lcov/lcov.info | coveralls"
    }
  },
  "dependencies": {
    "autoprefixer": "^6.5.0",
    "axios": "^0.14.0",
    "babel-core": "^6.16.0",
    "babel-polyfill": "^6.16.0",
    "babel-runtime": "^6.11.6",
    "chalk": "^1.1.3",
    "classnames": "^2.2.5",
    "compression": "^1.6.2",
    "express": "^4.14.0",
    "extract-text-webpack-plugin": "^2.0.0-beta.3",
    "flexboxgrid": "^6.3.1",
    "helmet": "^2.3.0",
    "hpp": "^0.2.1",
    "immutable": "^3.8.1",
    "material-ui": "^0.16.0",
    "morgan": "^1.7.0",
    "opn": "^4.0.2",
    "radium": "^0.18.1",
    "react": "^15.3.2",
    "react-addons-shallow-compare": "^15.3.2",
    "react-css-modules": "^3.7.10",
    "react-dom": "^15.3.2",
    "react-flexbox-grid": "^0.10.2",
    "react-helmet": "^3.1.0",
    "react-immutable-proptypes": "^2.1.0",
    "react-redux": "^4.4.5",
    "react-responsive": "^1.1.5",
    "react-router": "^2.8.1",
    "react-router-redux": "^4.0.6",
    "react-tap-event-plugin": "^1.0.0",
    "redbox-react": "^1.3.1",
    "redux": "^3.6.0",
    "redux-immutable": "^3.0.8",
    "redux-logger": "^2.7.0",
    "redux-thunk": "^2.1.0",
    "serialize-javascript": "^1.3.0",
    "serve-favicon": "^2.3.0",
    "stylelint-webpack-plugin": "^0.4.0",
    "webpack": "^2.1.0-beta.25",
    "webpack-dev-middleware": "^1.8.3",
    "webpack-hot-middleware": "^2.12.2",
    "webpack-isomorphic-tools": "^2.5.8"
  },
  "devDependencies": {
    "assets-webpack-plugin": "^3.4.0",
    "babel-eslint": "^7.0.0",
    "babel-loader": "^6.2.5",
    "babel-plugin-istanbul": "^2.0.1",
    "babel-plugin-system-import-transformer": "^2.4.0",
    "babel-plugin-transform-runtime": "^6.15.0",
    "babel-preset-latest": "^6.16.0",
    "babel-preset-react": "^6.16.0",
    "babel-preset-stage-0": "^6.16.0",
    "better-npm-run": "0.0.11",
    "chai": "^3.5.0",
    "chai-enzyme": "^0.5.2",
    "coveralls": "^2.11.14",
    "css-loader": "^0.25.0",
    "enzyme": "^2.4.1",
    "eslint": "^3.7.0",
    "eslint-config-airbnb": "^12.0.0",
    "eslint-loader": "^1.5.0",
    "eslint-plugin-import": "^2.0.0",
    "eslint-plugin-jsx-a11y": "^2.2.2",
    "eslint-plugin-react": "^6.3.0",
    "file-loader": "^0.9.0",
    "image-webpack-loader": "^2.0.0",
    "imports-loader": "^0.6.5",
    "json-loader": "^0.5.4",
    "karma": "^1.3.0",
    "karma-cli": "^1.0.1",
    "karma-coverage": "^1.1.1",
    "karma-mocha": "^1.2.0",
    "karma-mocha-reporter": "^2.2.0",
    "karma-phantomjs-launcher": "^1.0.2",
    "karma-sourcemap-loader": "^0.3.7",
    "karma-webpack": "^1.8.0",
    "mocha": "^3.1.0",
    "node-sass": "^3.10.1",
    "nodemon": "^1.10.2",
    "null-loader": "^0.1.1",
    "phantomjs": "^2.1.7",
    "postcss": "^5.2.4",
    "postcss-loader": "^0.13.0",
    "react-addons-test-utils": "^15.3.2",
    "react-hot-loader": "^3.0.0-beta.5",
    "redux-mock-store": "^1.2.1",
    "rimraf": "^2.5.4",
    "sass-loader": "^4.0.2",
    "sinon": "^2.0.0-pre.2",
    "style-loader": "^0.13.1",
    "stylelint": "^7.3.1",
    "stylelint-config-standard": "^13.0.2",
    "url-loader": "^0.5.7"
  }
}

[编辑] heroku日志

Hash: f14d96e1104722075ee5
2016-10-29T19:33:52.794597+00:00 app[web.1]: Version: webpack 2.1.0-beta.25
2016-10-29T19:33:52.794598+00:00 app[web.1]: Time: 36390ms
2016-10-29T19:33:52.794599+00:00 app[web.1]:                            Asset    Size  Chunks             Chunk Names
2016-10-29T19:33:52.794600+00:00 app[web.1]:      app.437ada71305f4f7f06fa.js  273 kB       0  [emitted]  app
2016-10-29T19:33:52.794602+00:00 app[web.1]: app.437ada71305f4f7f06fa.css.map   34 kB       0  [emitted]  app
2016-10-29T19:33 54% building modules 459/619 modules 160 active ...abel-runtime/core-js/object/assign.js
2016-10-29T19:33:52.794582+00:00 app[ 67% building modules 608/640 modules 32 active ...e-js/modules/_array-species-create.js
 66% building modules 800/846 modules 46 active ...ixer/lib/static/plugins/transitint.js
2016-10-29 64% building modules 566/625 modules 59 active ...index.js!/app/src/theme/normalize.css
 65% building modules 706/769 modules 63 active ...dules/core-js/library/modules/_has.js
 66% building modules 691/728 modules 37 active /app/node_modules/fbjs/lib/isTextNode.js
 66% building modules 828/875 modules 47 active ...react-addons-create-fragment/index.js
2016-10-29T19:33:52.794604+00:00 app[web.1]:     + 977 hidden modules
2016-10-29T19:33:52.794605+00:00 app[web.1]:         + 2 hidden modules
2016-10-29T19:33:52.794606+00:00 app[web.1]: Child extract-text-webpack-plugin:
2016-10-29T19:33:52.794607+00:00 app[web.1]:         + 2 hidden modules
2016-10-29T19:33:52.794608+00:00 app[web.1]: Child extract-text-webpack-plugin:
2016-10-29T19:33:52.794608+00:00 app[web.1]:         + 2 hidden modules
 68% building modules 872/888 modules 16 active ...materier/lib/utils/isPrefixedValue.js
2016-10-29T19:33:52.794603+00:00 app[web.1]:  [917] multi vendor 208 bytes {1} [built]
2016-10-29T19:33:52.794605+00:00 app[web.1]: Child extract-text-webpack-plugin:
 65% building modules 657/705 modules 48 active ...ct-flexbox-grid/lib/components/Col.js
2016-10- 66% building modules 768/821 modules 53 active ...refixer/lib/utils/unprefixProperty.js
 69% building modules 905/912 modules 8 active .../core-js/library/modules/_to-index.js
2016-10-29T19:33:52.794600+00:00 app[web.1]:   vendor.9d66707b3af690baefd1.js  410 kB       1  [emitted]  vendor
2016-10-29T19:33:52.794601+00:00 app[web.1]:     app.437ada71305f4f7f06fa.css   25 kB       0  [emitted]  app
2016-10-29T19:33:54.415735+00:00 app[web.1]:
2016-10-29T19:33:54.415747+00:00 app[web.1]: > Recipebook@1.0.0 start:prod /app
2016-10-29T19:33:54.415748+00:00 app[web.1]: > better-npm-run start:prod
2016-10-29T19:33:54.415749+00:00 app[web.1]:
2016-10-29T19:33:54.513444+00:00 app[web.1]: running better-npm-run in /app
2016-10-29T19:33:54.530984+00:00 app[web.1]: Executing script: start:prod
2016-10-29T19:33:54.535357+00:00 app[web.1]: to be executed: node ./index.js
2016-10-29T19:33:54.530987+00:00 app[web.1]:
2016-10-29T19:34:00.400261+00:00 app[web.1]: ==> �  Listening at http://localhost:8080
2016-10-29T19:34:08.828406+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2016-10-29T19:34:08.828500+00:00 heroku[web.1]: Stopping process with SIGKILL
2016-10-29T19:34:08.920786+00:00 heroku[web.1]: State changed from starting to crashed
2016-10-29T19:34:08.921680+00:00 heroku[web.1]: State changed from crashed to starting
2016-10-29T19:34:08.936050+00:00 heroku[web.1]: Process exited with status 137
2016-10-29T19:34:18.932898+00:00 heroku[web.1]: Starting process with command `npm run start:production`
2016-10-29T19:34:23.973344+00:00 app[web.1]:
2016-10-29T19:34:23.973368+00:00 app[web.1]: > Recipebook@1.0.0 start:production /app
2016-10-29T19:34:23.973369+00:00 app[web.1]: > npm run build && npm run start:prod
2016-10-29T19:34:23.973369+00:00 app[web.1]:
2016-10-29T19:34:27.052893+00:00 app[web.1]:
2016-10-29T19:34:27.052904+00:00 app[web.1]: > Recipebook@1.0.0 build /app
2016-10-29T19:34:27.052905+00:00 app[web.1]: > npm run clean:build && better-npm-run build
2016-10-29T19:34:27.052906+00:00 app[web.1]:
2016-10-29T19:34:29.508764+00:00 app[web.1]:
2016-10-29T19:34:29.508780+00:00 app[web.1]: > Recipebook@1.0.0 clean:build /app
2016-10-29T19:34:29.508781+00:00 app[web.1]: > better-npm-run clean:build
2016-10-29T19:34:29.508782+00:00 app[web.1]:
2016-10-29T19:34:29.771274+00:00 app[web.1]: running better-npm-run in /app
2016-10-29T19:34:29.791323+00:00 app[web.1]: Executing script: clean:build
2016-10-29T19:34:29.791326+00:00 app[web.1]:
2016-10-29T19:34:29.797335+00:00 app[web.1]: to be executed: rimraf ./public/dist
2016-10-29T19:34:30.876988+00:00 app[web.1]: running better-npm-run in /app
2016-10-29T19:34:31.135328+00:00 app[web.1]: Executing script: build
2016-10-29T19:34:31.135338+00:00 app[web.1]:
2016-10-29T19:34:31.175397+00:00 app[web.1]: to be executed: webpack --progress --display-error-details --config ./tools/webpack/config.babel
2016-10-29T19:35:19.343215+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2016-10-29T19:35:19.343215+00:00 heroku[web.1]: Stopping process with SIGKILL
 12% building modules 18/41 modules 23 active ...e_modules/react-router/lib/History.js
 15% building modules 49/68 modules 19 active ...odules/regenerator-runtime/runtime.js
2016-10-29T19 17% building modules 64/111 modules 47 active ...e_modules/axios/lib/helpers/spread.js
2016-10-29T19:35:19.401700+00:00 22% building modules 108/125 modules 17 active ...de_modules/lodash-es/isPlainObject.js
2016-10-29T19:35:19.40170 24% building modules 124/390 modules 266 active ...s/core-js/library/fn/set-immediate.js
2016-10-29T19:35:19.401700+00: 29% building modules 165/406 modules 241 active ...ules/babel-runtime/helpers/extends.js
 43% building modules 277/406 modules 129 active ...ules/babel-runtime/helpers/extends.js
 22% building modules 108/181 modules 73 active ...les/core-js/modules/es6.math.log1p.js
 56% building modules 384/412 modules 28 active ...ode_modules/lodash-es/isObjectLike.js
2016-10-29T19:35:19.40170 56% building modules 390/463 modules 73 active ...e_modules/core-js/modules/_classof.js
2016-10-29T19:35:19.401 22% building modules 108/238 modules 130 active ...s/core-js/modules/es6.regexp.match.js
2016-10-29T19:35:19.401700+00: 64% building modules 566/625 modules 59 active .../index.js!/app/src/constants/index.js
 64% building modules 619/686 modules 67 active ...s/library/modules/web.dom.iterable.js
 49% building modules 331/409 modules 78 active ...e_modules/react/lib/EventPluginHub.js
2016-10-29T19:35:19.401700+00:00 54% building modules 390/520 modules 130 active ..._modules/core-js/moes/_iter-create.js
 36% building modules 221/406 modules 185 active ...ules/babel-runtime/helpers/extends.js
 49% building modules 408/614 modules 206 active ...ules/core-js/library/modules/_core.js
 23% building modules 113/345 modules 232 active ...odules/react/lib/ReactCurrentOwner.js
 52% building modules 401/565 modules 164 active .../react/lib/ReactCompositeComponent.js
2016-10-29T19:35:19.401700+00:00 64% building modules 730/802 modules 72 active /app/node_modules/simple-assign/index.js
2016-10-29T19:35:19.4 66% building modules 607/641 modules 34 active ...node_modules/core-js/modules/_path.js
 54% building modules 460/618 modules 158 active ...abel-runtime/core-js/object/assign.js
2016-10-29T19:35:19.401700+0 60% building modules 516/618 modules 102 active ...abel-runtime/core-js/object/assign.js
 22% building modules 108/294 modules 186 active ...les/core-js/modules/es7.math.imulh.js
2016-10-29T19:35 65% building modules 707/768 modules 61 active ...odules/axios/lib/core/enhanceError.js
 66% building modules 768/821 modules 53 active ...refixer/lib/utils/unprefixProperty.js
 66% building modules 690/728 modules 38 active /app/node_modules/fbjs/lib/isTextNode.js
 65% building modules 657/705 modules 48 active ...ct-flexbox-grid/lib/components/Col.js
2016-10-29T19:35 66% building modules 800/846 modules 46 active ...ixer/lib/static/plugins/transition.js
 66% building modules 828/875 modules 47 active ...react-addons-create-fragment/index.js
 68% building modules 869/887 modules 18 active ...prefixer/lib/utils/isPrefixedValue.jsError waiting for process to terminate: No child processes
2016-10-29T19:35:19.532075+00:00 heroku[web.1]: Process exited with status 22
2016-10-29T19:35:19.533651+00:00 heroku[web.1]: State changed from starting to crashed
2016-10-29T19:41:05.532116+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=evening-retreat-75182.herokuapp.com request_id=f7e80c38-c84b-4f75-9478-59d782c1e112 fwd="207.244.90.77" dyno= connect= service= status=503 bytes=
2016-10-29T19:41:09.449918+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=evening-retreat-75182.herokuapp.com request_id=93c05f33-7ec5-4b5f-8409-f218c159a020 fwd="207.244.90.77" dyno= connect= service= status=503 bytes=
2016-10-29T19:41:15.280404+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=evening-retreat-75182.herokuapp.com request_id=3b8fd867-6383-4a6a-bf01-b3e379f05225 fwd="207.244.90.77" dyno= connect= service= status=503 bytes=
2016-10-29T19:41:16.426158+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=evening-retreat-75182.herokuapp.com request_id=1dd69267-6fcc-4ab4-ad0e-00a985606a18 fwd="207.244.90.77" dyno= connect= service= status=503 bytes=

1 个答案:

答案 0 :(得分:0)

问题是您不能直接在CLI中使用better-npm-run

您需要使用shell-exec并指定命令。

查看官方文档:https://www.npmjs.com/package/better-npm-run#cli-commands

[编辑] 将better-npm-run移至dependencies或让heroku安装devDependencies

参考:https://devcenter.heroku.com/articles/nodejs-support#devdependencies

Heroku动态绑定端口号,因此您需要使用process.env.PORT来获取动态分配的端口。与this类似的东西。

希望这有帮助!

相关问题