Heroku应用程序崩溃:at=error code=H10 desc=“App crashed”method=GET path="/”

h7wcgrx3  于 12个月前  发布在  其他
关注(0)|答案(6)|浏览(166)
  • 我一直在尝试将我的MERN应用程序上传到Heroku,并一直收到这些错误代码。Web应用程序将在我的本地主机上运行,但当我尝试将其上传到Heroku时,应用程序立即失败。我对使用MERN堆栈相对较新,正在尝试弄清楚如何正确地将应用程序上传到Heroku。*
2020-05-26T05:00:40.804369+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=murmuring-fjord-39421.herokuapp.com request_id=9c5806e4-dd49-4325-8814-dccb9f4398e0 fwd="71.204.55.234" dyno= connect= service= status=503 bytes= protocol=https
2020-05-26T05:00:41.404224+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=murmuring-fjord-39421.herokuapp.com request_id=c325a3c6-b459-4de2-b7f5-fe67457f8d6e fwd="71.204.55.234" dyno= connect= service= status=503 bytes= protocol=httpsenter code here
2020-05-26T05:01:09.373344+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=murmuring-fjord-39421.herokuapp.com request_id=4ad4f358-063e-48d7-a55e-7ccffc32ffb3 fwd="71.204.55.234" dyno= connect= service= status=503 bytes= protocol=httpsenter code here

字符串

heroku日志-尾巴

2020-05-26T04:54:22.910425+00:00 app[api]: Initial release by user [email protected]
2020-05-26T04:54:22.910425+00:00 app[api]: Release v1 created by user [email protected]
2020-05-26T04:54:23.096112+00:00 app[api]: Enable Logplex by user [email protected]
2020-05-26T04:54:23.096112+00:00 app[api]: Release v2 created by user [email protected]
2020-05-26T04:58:40.000000+00:00 app[api]: Build started by user [email protected]
2020-05-26T04:59:47.263635+00:00 app[api]: Deploy 7d333fc9 by user [email protected]
2020-05-26T04:59:47.263635+00:00 app[api]: Release v3 created by user [email protected]
2020-05-26T04:59:47.283454+00:00 app[api]: Scaled to web@1:Free by user [email protected]
2020-05-26T04:59:54.000000+00:00 app[api]: Build succeeded
2020-05-26T04:59:56.664155+00:00 heroku[web.1]: Starting process with command `npm start`
2020-05-26T04:59:59.487422+00:00 app[web.1]:
2020-05-26T04:59:59.487434+00:00 app[web.1]: > [email protected] start /app
2020-05-26T04:59:59.487434+00:00 app[web.1]: > react-scripts start
2020-05-26T04:59:59.487435+00:00 app[web.1]:
2020-05-26T05:00:02.028314+00:00 app[web.1]: ℹ 「wds」: Project is running at http://172.17.10.22/
2020-05-26T05:00:02.028881+00:00 app[web.1]: ℹ 「wds」: webpack output is served from
2020-05-26T05:00:02.029021+00:00 app[web.1]: ℹ 「wds」: Content not from webpack is served from /app/public
2020-05-26T05:00:02.029167+00:00 app[web.1]: ℹ 「wds」: 404s will fallback to /
2020-05-26T05:00:02.029361+00:00 app[web.1]: Starting the development server...
2020-05-26T05:00:02.029362+00:00 app[web.1]: 
2020-05-26T05:00:02.141290+00:00 heroku[web.1]: Process exited with status 0
2020-05-26T05:00:02.315545+00:00 heroku[web.1]: State changed from starting to crashed
2020-05-26T05:00:02.318095+00:00 heroku[web.1]: State changed from crashed to starting
2020-05-26T05:00:09.983236+00:00 heroku[web.1]: Starting process with command `npm start`
2020-05-26T05:00:12.651901+00:00 app[web.1]: 
2020-05-26T05:00:12.651922+00:00 app[web.1]: > [email protected] start /app
2020-05-26T05:00:12.651923+00:00 app[web.1]: > react-scripts start
2020-05-26T05:00:12.651923+00:00 app[web.1]:
2020-05-26T05:00:16.868981+00:00 app[web.1]: ℹ 「wds」: Project is running at http://172.17.178.250/
2020-05-26T05:00:16.869628+00:00 app[web.1]: ℹ 「wds」: webpack output is served from
2020-05-26T05:00:16.869783+00:00 app[web.1]: ℹ 「wds」: Content not from webpack is served from /app/public
2020-05-26T05:00:16.869929+00:00 app[web.1]: ℹ 「wds」: 404s will fallback to /
2020-05-26T05:00:16.870239+00:00 app[web.1]: Starting the development server...
2020-05-26T05:00:16.870241+00:00 app[web.1]: 
2020-05-26T05:00:17.013391+00:00 heroku[web.1]: Process exited with status 0
2020-05-26T05:00:17.057205+00:00 heroku[web.1]: State changed from starting to crashed
2020-05-26T05:00:40.804369+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=murmuring-fjord-39421.herokuapp.com request_id=9c5806e4-dd49-4325-8814-dccb9f4398e0 fwd="71.204.55.234" dyno= connect= service= status=503 bytes= protocol=https
2020-05-26T05:00:41.404224+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=murmuring-fjord-39421.herokuapp.com request_id=c325a3c6-b459-4de2-b7f5-fe67457f8d6e fwd="71.204.55.234" dyno= connect= service= status=503 bytes= protocol=https
2020-05-26T05:01:09.373344+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=murmuring-fjord-39421.herokuapp.com request_id=4ad4f358-063e-48d7-a55e-7ccffc32ffb3 fwd="71.204.55.234" dyno= connect= service= status=503 bytes= protocol=https
2020-05-26T05:11:05.245937+00:00 heroku[web.1]: State changed from crashed to starting
2020-05-26T05:11:14.187854+00:00 heroku[web.1]: Starting process with command `npm start`
2020-05-26T05:11:16.938860+00:00 app[web.1]:
2020-05-26T05:11:16.938887+00:00 app[web.1]: > [email protected] start /app
2020-05-26T05:11:16.938887+00:00 app[web.1]: > react-scripts start
2020-05-26T05:11:16.938887+00:00 app[web.1]: 
2020-05-26T05:11:18.963210+00:00 app[web.1]: ℹ 「wds」: Project is running at http://172.19.50.2/
2020-05-26T05:11:18.963807+00:00 app[web.1]: ℹ 「wds」: webpack output is served from
2020-05-26T05:11:18.963915+00:00 app[web.1]: ℹ 「wds」: Content not from webpack is served from /app/public
2020-05-26T05:11:18.964030+00:00 app[web.1]: ℹ 「wds」: 404s will fallback to /
2020-05-26T05:11:18.964316+00:00 app[web.1]: Starting the development server...
2020-05-26T05:11:18.964319+00:00 app[web.1]: 
2020-05-26T05:11:19.093706+00:00 heroku[web.1]: Process exited with status 0
2020-05-26T05:11:19.137119+00:00 heroku[web.1]: State changed from starting to crashed
2020-05-26T05:11:19.140236+00:00 heroku[web.1]: State changed from crashed to starting
2020-05-26T05:11:26.041885+00:00 heroku[web.1]: Starting process with command `npm start`
2020-05-26T05:11:28.043546+00:00 app[web.1]: 
2020-05-26T05:11:28.043558+00:00 app[web.1]: > [email protected] start /app
2020-05-26T05:11:28.043558+00:00 app[web.1]: > react-scripts start
2020-05-26T05:11:28.043559+00:00 app[web.1]:
2020-05-26T05:11:29.727646+00:00 app[web.1]: ℹ 「wds」: Project is running at http://172.16.13.198/
2020-05-26T05:11:29.727983+00:00 app[web.1]: ℹ 「wds」: webpack output is served from
2020-05-26T05:11:29.728062+00:00 app[web.1]: ℹ 「wds」: Content not from webpack is served from /app/public
2020-05-26T05:11:29.728128+00:00 app[web.1]: ℹ 「wds」: 404s will fallback to /
2020-05-26T05:11:29.728294+00:00 app[web.1]: Starting the development server...
2020-05-26T05:11:29.728295+00:00 app[web.1]:
2020-05-26T05:11:29.800107+00:00 heroku[web.1]: Process exited with status 0
2020-05-26T05:11:29.835462+00:00 heroku[web.1]: State changed from starting to crashed

  • server.js文件 *
const bodyParser = require('body-parser');
const cors = require('cors');
const path = require('path')
const app = express();
require('./database');

app.use(bodyParser.json());
app.use(cors());

// API
const users = require('./api/users');
app.use('/api/users', users);

app.use(express.static(path.join(__dirname, '../build')))
app.get('*', (req, res) => {
    res.sendFile(path.join(__dirname, '../build'))
})

const port = process.env.PORT || 5000;
app.listen(port, () => {
    console.log(`Server started on port ${port}`);
});

  • package.json文件 *
{
  "name": "my-project",
  "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",
    "axios": "^0.19.2",
    "body-parser": "^1.19.0",
    "bootstrap": "^4.5.0",
    "cors": "^2.8.5",
    "express": "^4.17.1",
    "mongoose": "^5.9.15",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-scripts": "3.4.1"
  },
  "scripts": {
    "start": "node backend/server.js",
    "heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install npm && run build",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "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"
    ]
  },
  "proxy": "http://localhost:5000",
  "engines": {
    "node": "10.16.0"
  }
}

oxalkeyp

oxalkeyp1#

对我来说,在检查了其他所有内容之后,问题出在空路径上。
不要使用空Path -->“/”部署API
总是给它一个给予这样的路径--> '/API/data'
空路径会让API认为favicon.ico是您试图传递的ID.
在我的情况下,例如我用途:
app.use("/API/emps”,require('./routes/employees. routes'))

ql3eal8s

ql3eal8s2#

我也面临着同样的问题(在本地运行良好,但在heroku上与我的MERN堆栈崩溃);虽然我的编码与查询中提到的有点不同。然后我找到了一个页面,其中提到了大多数可能发生的原因(链接是https://dev.to/lawrence_eagles/causes-of-heroku-h10-app-crashed-error-and-how-to-solve-them-3jnl)。我也尝试了所有的方法,但对我来说都不起作用。但在评论部分,人们提到了代码中的以下更改
需要在命令模块“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”}







以上这些改变对我很有效,希望对你有帮助

7y4bm7vi

7y4bm7vi3#

这可以通过两种方式解决:
1)如果您忘记设置启动脚本,通常会抛出此错误!Heroku要求将Procfile(如果您想覆盖Heroku的默认启动命令)与您的应用文件一起上传沿着。
Procfile的内容应该是这样的:
web: node index.js(即指定要为应用程序运行的node命令)
2)如果你不想上传一个Procfile,那么你可以在package.json中的"scripts"中指定你的命令(你已经做了),同时你需要在package.json中添加"build":"webpack"
你还用"heroku-postbuild"替换了"build"脚本..

wn9m85ua

wn9m85ua4#

把这个添加到你的server.js中:

var distDir = __dirname + "/dist/";

app.use(express.static(distDir));

字符串

qacovj5a

qacovj5a5#

在React中,我做了两件事。一件解决了:)
1.使用https://favicon.io/favicon-converter/添加了favicon和manifest
1.从package.json中删除了未使用的软件包,您还应该向devDependencies添加开发依赖项

acruukt9

acruukt96#

我已经把这段代码放在json文件中,从那时起它就完美地工作了

scripts": {
    "start": "node index.js"
}

字符串

相关问题