gpt4 book ai didi

javascript - 部署 Heroku 时应用程序崩溃(代码 h10)

转载 作者:行者123 更新时间:2023-12-02 23:27:37 26 4
gpt4 key购买 nike

我正在尝试将我的应用程序部署到 Heroku,但我一直崩溃。我使用 CLI 打开我的应用程序,它仍然崩溃,我什至在 Keroku 仪表板上部署分支,它仍然崩溃。我想知道我的 app.js 或 packjson 有什么问题

这是我得到的错误:

2019-06-19T12:32:14.679424+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=guarded-island-18465.herokuapp.com request_id=66a60c63-3bad-47ad-8255-85f56798df95fwd="97.99.40.66" dyno= connect= service= status=503 bytes= protocol=https2019-06-19T12:32:15.283697+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=guarded-island-18465.herokuapp.com request_id=888cb97b-7aaf-4e0b-97c5-d01432d188a6 fwd="97.99.40.66" dyno= connect= service= status=503 bytes= protocol=https

{
"name": "newburger2",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node app.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/jnperk1234/neweatdaburger.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/jnperk1234/neweatdaburger/issues"
},
"homepage": "https://github.com/jnperk1234/neweatdaburger#readme",
"dependencies": {
"body-parser": "^1.19.0",
"express": "^4.17.1",
"express-handlebars": "^3.1.0",
"mongodb": "^3.2.6",
"mysql": "^2.17.1"
}
}

var express = require("express");
var bodyParser = require("body-parser");
var exphbs = require("express-handlebars");

var app = express();
var PORT = process.env.PORT || 3000;

app.use(express.static("public"));

app.use(bodyParser.urlencoded({
extended: true
}));
app.use(bodyParser.json());

app.engine("handlebars", exphbs({
defaultLayout: "main"
}));
app.set("view engine", "handlebars");

var routes = require("./controllers/burgers_controller.js");
app.use(routes);

app.listen(port, "0.0.0.0", function () {
console.log("Listening on Port 3000");
});

最佳答案

这对我有帮助。部署时默认的构建包是node.js。您需要使用 create-react-app 构建包(如下所示)。

heroku create $APP_NAME --buildpack mars/create-react-app
git push heroku master
heroku open

关于javascript - 部署 Heroku 时应用程序崩溃(代码 h10),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56667968/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com