Heroku deploy error H10

I was trying to find my case but did not work, so I make a new topic.
/Folder
– /public
----/img
----/css
----/js
----html
server.js
package.json

So the tree is like this and when I run with server.js in localhost:8080, it works well.
However, when I deploy my app on heroku,

2020-10-11T07:34:57.041259+00:00 heroku[router]: at=error code=H10 desc=“App crashed” method=GET path="/" host=quiet-caverns-08930.herokuapp.com request_id=b76d2262-a3a1-4487-bc6a-c456b027cb9e fwd=“99.240.194.182” dyno= connect= service= status=503 bytes= protocol=https
2020-10-11T07:34:58.403593+00:00 heroku[router]: at=error code=H10 desc=“App crashed” method=GET path="/favicon.ico" host=quiet-caverns-08930.herokuapp.com request_id=60b59bfc-fe98-4cef-9e69-0366952d60ed fwd=“99.240.194.182” dyno= connect= service= status=503 bytes= protocol=https

And goes same.
I tried

heroku restart

and did not work at all.

my “package.json” is like

{

  "name": "folder",

  "version": "1.0.0",

  "engines":{

    "node": "v14.4.0",

    "npm": "6.14.5"

  },

  "description": "Folder",

  "main": "server.js",

  "scripts": {

    "test": "echo \"Error: no test specified\" && exit 1",

    "start": "node server.js"

  },

  "keywords": [

  ],

  "author": "MyName",

  "license": "MIT",

  "dependencies": {

    "express": "^4.17.1",

    "heroku": "^7.43.2"

  },

  "devDependencies": {}

}

and also the server.js is

var HTTP = process.env.HTTP || 8080;

var express = require("express");

var app = express();

var path = require("path");

app.set("port", HTTP_PORT); //added

function onListen () {
    console.log("Express server listening on port %d in %s mode", this.address().port, app.settings.env);
}

app.listen(HTTP_PORT, onListen);

I did everything. Now I can not sure. What should I do more now??
Please, please let me know. Help me.

Welcome, vellasy.

The error is telling you the problem:

at=error code=H10 desc=“App crashed” method=GET path=“/”

You have not told your app what to do at the / (home) route. I suggest you look into routing, if you have not.

Also, freeCodeCamp has lessons covering this topic:


I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').