简体   繁体   English

Heroku 产生错误 H10 并导致应用程序崩溃

[英]Heroku producing Error H10 and crashing app

I'm using nodejs + reactjs + express + mongodb我正在使用nodejs + reactjs + express + mongodb

Deployed my backend on another server and its works perfectly fine.将我的后端部署在另一台服务器上,它的工作非常好。

But when i accessing frontend it showing "H10" error and when i run this same project using heroku local its works perfectly fine.但是当我访问前端时,它显示“H10”错误,当我使用heroku local运行同一个项目时,它的工作非常好。

My package.json我的 package.json

{
  "name": "ecommerce",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "braintree-web-drop-in-react": "^1.1.1",
    "concurrently": "^5.2.0",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-router-dom": "^5.1.2",
    "react-scripts": "3.4.1",
    "react-stripe-checkout": "^2.6.3"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "heroku-postbuild": "npm run build"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "engines": {
    "node": "10.x",
    "npm": "6.x"
  }
}

Logs that i get:我得到的日志:

2020-04-25T18:04:45.413902+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=ecommerce-frontend-dweep.herokuapp.com request_id=0d7f7627-3a3e-4a79-8221-b09f89fb49d0 fwd="103.240.77.140" dyno= connect= service= status=503 bytes= protocol=https
2020-04-25T18:04:46.267420+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=ecommerce-frontend-dweep.herokuapp.com request_id=30e4c07f-fd30-4210-8158-dabbd7d196f9 fwd="103.240.77.140" dyno= connect= service= status=503 bytes= protocol=https

Also run heroku run node console同时运行heroku run node console

Output (incase it required): Output(如果需要):

internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module '/app/console'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)

Already tried solution of First Heroku deploy failed `error code=H10` but it didn't work已经尝试过First Heroku deploy failed `error code=H10`的解决方案,但没有成功

Same problem for me, and after following the steps bellow it worked perfectly:对我来说同样的问题,按照下面的步骤后它工作得很好:

First try and install serve首先尝试安装服务

npm install serve --s

then replace your scripts in the package.json by this:然后将 package.json 中的脚本替换为:

"scripts": {
"dev": "react-scripts start",
"start": "serve -s build",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"heroku-postbuild": "npm run build"
}

after that add, commit and push to heroku之后添加,提交并推送到 heroku

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM