我的React / Node应用程序可以在本地运行,但不能在Heroku上运行

时间:2018-10-14 09:53:49

标签: node.js reactjs express heroku

首先,请再次记住我之前,请记住在来到这里寻求帮助之前,我花了整个星期六的时间来解决这个问题,并且由于昨日压力太大,不得不昨晚带Xanax入睡。

Here is the popular Medium article that I broadly followed

Here is my github repo

Here is the heroku link


我很确定问题与package.json文件

有关

package.json

{
  "name": "example-create-react-app-express",
  "version": "1.0.0",
  "scripts": {
  "client": "cd client && yarn start",
  "server": "nodemon --experimental-modules server.mjs",
  "dev": "concurrently --kill-others-on-fail \"npm run server --experimental-modules \" \"npm run client --experimental-modules\"",
  "start": "npm server.mjs --experimental-modules",
  "heroku-postbuild": "cd client && npm install --experimental-modules && npm install --experimental-modules --only=dev --no-shrinkwrap && npm run build --experimental-modules"
},
"dependencies": {
  "axios": "^0.18.0",
  "body-parser": "^1.18.3",
  "express": "^4.16.3",
  "lorem-ipsum": "^1.0.6",
  "mongoose": "^5.2.10",
  "shortid": "^2.2.13",
  "uuid": "^3.3.2"
},
  "devDependencies": {
  "concurrently": "^3.5.0",
  "dotenv": "^6.0.0"
},
  "main": "index.js",
  "repository": "git@github.com:HenryPTS/keirei.git",
  "author": "HenryPTS <steinbergvhenry@gmail.com>",
  "license": "MIT"
}


client / package.json

{
  "name": "keirei",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "autoprefixer": "7.1.6",
    "babel-core": "6.26.0",
    "babel-eslint": "7.2.3",
    "babel-jest": "20.0.3",
    "babel-loader": "7.1.2",
    "babel-preset-react-app": "^3.1.2",
    "babel-runtime": "6.26.0",
    "case-sensitive-paths-webpack-plugin": "2.1.1",
    "chalk": "1.1.3",
    "css-loader": "0.28.7",
    "dotenv": "4.0.0",
    "dotenv-expand": "4.2.0",
    "eslint": "4.10.0",
    "eslint-config-react-app": "^2.1.0",
    "eslint-loader": "1.9.0",
    "eslint-plugin-flowtype": "2.39.1",
    "eslint-plugin-import": "2.8.0",
    "eslint-plugin-jsx-a11y": "5.1.1",
    "eslint-plugin-react": "7.4.0",
    "extract-text-webpack-plugin": "3.0.2",
    "file-loader": "1.1.5",
    "fs-extra": "3.0.1",
    "html-webpack-plugin": "2.29.0",
    "jest": "20.0.4",
    "object-assign": "4.1.1",
    "postcss-flexbugs-fixes": "3.2.0",
    "postcss-loader": "2.0.8",
    "promise": "8.0.1",
    "raf": "3.4.0",
    "react": "^16.4.2",
    "react-dev-utils": "^5.0.2",
    "react-dom": "^16.4.2",
    "react-router": "^4.3.1",
    "react-router-dom": "^4.3.1",
    "resolve": "1.6.0",
    "style-loader": "0.19.0",
    "sw-precache-webpack-plugin": "0.11.4",
    "url-loader": "0.6.2",
    "webpack": "3.8.1",
    "webpack-dev-server": "2.11.3",
    "webpack-manifest-plugin": "1.3.2",
    "whatwg-fetch": "2.0.3"
  },
  "scripts": {
    "start": "node scripts/start.js",
    "build": "node scripts/build.js",
    "test": "node scripts/test.js --env=jsdom"
  },
  "proxy": "http://localhost:5000/",
  "jest": {
    "collectCoverageFrom": [
      "src/**/*.{js,jsx,mjs}"
    ],
    "setupFiles": [
      "<rootDir>/config/polyfills.js"
    ],
    "testMatch": [
      "<rootDir>/src/**/__tests__/**/*.{js,jsx,mjs}",
      "<rootDir>/src/**/?(*.)(spec|test).{js,jsx,mjs}"
    ],
    "testEnvironment": "node",
    "testURL": "http://localhost",
    "transform": {
      "^.+\\.(js|jsx|mjs)$": "<rootDir>/node_modules/babel-jest",
      "^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
      "^(?!.*\\.(js|jsx|mjs|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
    },
    "transformIgnorePatterns": [
      "[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs)$"
    ],
    "moduleNameMapper": {
      "^react-native$": "react-native-web"
    },
    "moduleFileExtensions": [
      "web.js",
      "js",
      "json",
      "web.jsx",
      "jsx",
      "node",
      "mjs"
    ]
  },
  "babel": {
    "presets": [
      "react-app"
    ]
  },
  "eslintConfig": {
    "extends": "react-app"
  }
}


heroku日志的输出--tails

2018-10-13T22:19:34.355903+00:00 app[web.1]: npm ERR! example-create-react-app-express@1.0.0 start: `npm server.mjs --experimental-modules`
2018-10-13T22:19:34.355906+00:00 app[web.1]: npm ERR! Exit status 1
2018-10-13T22:19:34.355908+00:00 app[web.1]: npm ERR!
2018-10-13T22:19:34.355911+00:00 app[web.1]: npm ERR! Failed at the example-create-react-app-express@1.0.0 start script.
2018-10-13T22:19:34.355913+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2018-10-13T22:19:34.384903+00:00 app[web.1]:
2018-10-13T22:19:34.384911+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2018-10-13T22_19_34_357Z-debug.log
2018-10-13T22:19:34.384909+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2018-10-14T03:55:54.538494+00:00 heroku[web.1]: State changed from crashed to starting
2018-10-14T03:56:03.922469+00:00 heroku[web.1]: Starting process with command `npm start`
2018-10-14T03:56:07.134337+00:00 app[web.1]: > npm server.mjs --experimental-modules
2018-10-14T03:56:07.134338+00:00 app[web.1]:
2018-10-14T03:56:07.134335+00:00 app[web.1]: > example-create-react-app-express@1.0.0 start /app
2018-10-14T03:56:07.134317+00:00 app[web.1]:
2018-10-14T03:56:07.660715+00:00 heroku[web.1]: Process exited with status 1
2018-10-14T03:56:07.677072+00:00 heroku[web.1]: State changed from starting to crashed
2018-10-14T03:56:07.531845+00:00 app[web.1]:
2018-10-14T03:56:07.531864+00:00 app[web.1]: Usage: npm <command>
2018-10-14T03:56:07.531865+00:00 app[web.1]:
2018-10-14T03:56:07.531867+00:00 app[web.1]: where <command> is one of:
2018-10-14T03:56:07.531873+00:00 app[web.1]:     completion, config, create, ddp, dedupe, deprecate,
2018-10-14T03:56:07.531879+00:00 app[web.1]:     help-search, hook, i, init, install, install-test, it, link,
2018-10-14T03:56:07.531880+00:00 app[web.1]:     list, ln, login, logout, ls, outdated, owner, pack, ping,
2018-10-14T03:56:07.531881+00:00 app[web.1]:     prefix, profile, prune, publish, rb, rebuild, repo, restart,
2018-10-14T03:56:07.531872+00:00 app[web.1]:     access, adduser, audit, bin, bugs, c, cache, ci, cit,
2018-10-14T03:56:07.531883+00:00 app[web.1]:     root, run, run-script, s, se, search, set, shrinkwrap, star,
2018-10-14T03:56:07.531874+00:00 app[web.1]:     dist-tag, docs, doctor, edit, explore, get, help,
2018-10-14T03:56:07.531884+00:00 app[web.1]:     stars, start, stop, t, team, test, token, tst, un,
2018-10-14T03:56:07.531885+00:00 app[web.1]:     uninstall, unpublish, unstar, up, update, v, version, view,
2018-10-14T03:56:07.531886+00:00 app[web.1]:     whoami
2018-10-14T03:56:07.531892+00:00 app[web.1]: npm <command> -h  quick help on <command>
2018-10-14T03:56:07.531895+00:00 app[web.1]: npm help <term>   search for help on <term>
2018-10-14T03:56:07.531896+00:00 app[web.1]: npm help npm      involved overview
2018-10-14T03:56:07.531887+00:00 app[web.1]:
2018-10-14T03:56:07.531897+00:00 app[web.1]:
2018-10-14T03:56:07.531898+00:00 app[web.1]: Specify configs in the ini-formatted file:
2018-10-14T03:56:07.531893+00:00 app[web.1]: npm -l            display full usage info
2018-10-14T03:56:07.531899+00:00 app[web.1]:     /app/.npmrc
2018-10-14T03:56:07.531900+00:00 app[web.1]: or on the command line via: npm <command> --key value
2018-10-14T03:56:07.531904+00:00 app[web.1]: npm@6.4.1 /app/.heroku/node/lib/node_modules/npm
2018-10-14T03:56:07.531902+00:00 app[web.1]: Config info can be viewed via: npm help config
2018-10-14T03:56:07.557221+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2018-10-14T03:56:07.557696+00:00 app[web.1]: npm ERR! errno 1
2018-10-14T03:56:07.559431+00:00 app[web.1]: npm ERR! example-create-react-app-express@1.0.0 start: `npm server.mjs --experimental-modules`
2018-10-14T03:56:07.559639+00:00 app[web.1]: npm ERR! Exit status 1
2018-10-14T03:56:07.531903+00:00 app[web.1]:
2018-10-14T03:56:07.559927+00:00 app[web.1]: npm ERR!
2018-10-14T03:56:07.538679+00:00 app[web.1]:
2018-10-14T03:56:07.560174+00:00 app[web.1]: npm ERR! Failed at the example-create-react-app-express@1.0.0 start script.
2018-10-14T03:56:07.560363+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2018-10-14T03:56:07.584098+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2018-10-14T03:56:07.576127+00:00 app[web.1]:
2018-10-14T03:56:07.584103+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2018-10-14T03_56_07_562Z-debug.log
2018-10-14T09:40:27.916447+00:00 heroku[web.1]: State changed from crashed to starting
2018-10-14T09:40:37.545339+00:00 heroku[web.1]: Starting process with command `npm start`
2018-10-14T09:40:40.686480+00:00 app[web.1]:
2018-10-14T09:40:40.686507+00:00 app[web.1]:
2018-10-14T09:40:40.686504+00:00 app[web.1]: > example-create-react-app-express@1.0.0 start /app
2018-10-14T09:40:40.686506+00:00 app[web.1]: > npm server.mjs --experimental-modules
2018-10-14T09:40:41.864389+00:00 heroku[web.1]: Process exited with status 1
2018-10-14T09:40:41.922343+00:00 heroku[web.1]: State changed from starting to crashed
2018-10-14T09:40:41.681977+00:00 app[web.1]:
2018-10-14T09:40:41.682010+00:00 app[web.1]: Usage: npm <command>
2018-10-14T09:40:41.682011+00:00 app[web.1]:
2018-10-14T09:40:41.682013+00:00 app[web.1]: where <command> is one of:
2018-10-14T09:40:41.682014+00:00 app[web.1]:     access, adduser, audit, bin, bugs, c, cache, ci, cit,
2018-10-14T09:40:41.682016+00:00 app[web.1]:     completion, config, create, ddp, dedupe, deprecate,
2018-10-14T09:40:41.682017+00:00 app[web.1]:     dist-tag, docs, doctor, edit, explore, get, help,
2018-10-14T09:40:41.682020+00:00 app[web.1]:     list, ln, login, logout, ls, outdated, owner, pack, ping,
2018-10-14T09:40:41.682019+00:00 app[web.1]:     help-search, hook, i, init, install, install-test, it, link,
2018-10-14T09:40:41.682021+00:00 app[web.1]:     prefix, profile, prune, publish, rb, rebuild, repo, restart,
2018-10-14T09:40:41.682024+00:00 app[web.1]:     stars, start, stop, t, team, test, token, tst, un,
2018-10-14T09:40:41.682023+00:00 app[web.1]:     root, run, run-script, s, se, search, set, shrinkwrap, star,
2018-10-14T09:40:41.682025+00:00 app[web.1]:     uninstall, unpublish, unstar, up, update, v, version, view,
2018-10-14T09:40:41.682043+00:00 app[web.1]:     whoami
2018-10-14T09:40:41.682044+00:00 app[web.1]:
2018-10-14T09:40:41.682046+00:00 app[web.1]: npm <command> -h  quick help on <command>
2018-10-14T09:40:41.682047+00:00 app[web.1]: npm -l            display full usage info
2018-10-14T09:40:41.682049+00:00 app[web.1]: npm help <term>   search for help on <term>
2018-10-14T09:40:41.682050+00:00 app[web.1]: npm help npm      involved overview
2018-10-14T09:40:41.682051+00:00 app[web.1]:
2018-10-14T09:40:41.682053+00:00 app[web.1]: Specify configs in the ini-formatted file:
2018-10-14T09:40:41.682054+00:00 app[web.1]:     /app/.npmrc
2018-10-14T09:40:41.682055+00:00 app[web.1]: or on the command line via: npm <command> --key value
2018-10-14T09:40:41.682057+00:00 app[web.1]: Config info can be viewed via: npm help config
2018-10-14T09:40:41.682058+00:00 app[web.1]:
2018-10-14T09:40:41.682059+00:00 app[web.1]: npm@6.4.1 /app/.heroku/node/lib/node_modules/npm
2018-10-14T09:40:41.696647+00:00 app[web.1]:
2018-10-14T09:40:41.726240+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2018-10-14T09:40:41.726891+00:00 app[web.1]: npm ERR! errno 1
2018-10-14T09:40:41.729370+00:00 app[web.1]: npm ERR! example-create-react-app-express@1.0.0 start: `npm server.mjs --experimental-modules`
2018-10-14T09:40:41.729679+00:00 app[web.1]: npm ERR! Exit status 1
2018-10-14T09:40:41.730068+00:00 app[web.1]: npm ERR!
2018-10-14T09:40:41.730338+00:00 app[web.1]: npm ERR! Failed at the example-create-react-app-express@1.0.0 start script.
2018-10-14T09:40:41.730657+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2018-10-14T09:40:41.753088+00:00 app[web.1]:
2018-10-14T09:40:41.753715+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2018-10-14T09:40:41.754237+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2018-10-14T09_40_41_733Z-debug.log
2018-10-14T09:45:51.746113+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=keirei.herokuapp.com request_id=77433bae-0184-481d-8c4e-d91ec8ae6618 fwd="86.5.20.156" dyno= connect= service= status=503 bytes= protocol=https
2018-10-14T09:45:53.089110+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=keirei.herokuapp.com request_id=d7039d9e-82c4-4513-bfce-be4e534de0b4 fwd="86.5.20.156" dyno= connect= service= status=503 bytes= protocol=https


连接到服务器所需的.env变量是:

DB_URI=mongodb://ds135952.mlab.com:35952/keirei-db
DB_USER=admin
DB_PASS=limit5


同样,在拒绝投票之前,请记住我是一个缺乏智力的新人,并且在来到这里之前做出了自己的真诚一致努力来解决问题。

0 个答案:

没有答案