[英]Heroku producing Error H10 and crashing app
我正在使用nodejs + reactjs + express + mongodb
將我的后端部署在另一台服務器上,它的工作非常好。
但是當我訪問前端時,它顯示“H10”錯誤,當我使用heroku local
運行同一個項目時,它的工作非常好。
我的 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"
}
}
我得到的日志:
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
同時運行heroku run node console
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)
已經嘗試過First Heroku deploy failed `error code=H10`的解決方案,但沒有成功
對我來說同樣的問題,按照下面的步驟后它工作得很好:
首先嘗試安裝服務
npm install serve --s
然后將 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"
}
之后添加,提交並推送到 heroku
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.