'Error when deploying socket.io server on heroku

I am trying to deploy my socket.io server onto heroku yet I keep getting errors. This is my code for the server:

var app = require('express')();
var http = require('http').createServer(app);

app.get('/', function(req, res) {
    res.send({response: "Server is running."}).status(200);
})

const io = require('socket.io')(http, {
    cors: {
        origin: "*",
    },
});

This is my package.json:

{
  "name": "server",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "node index.js",
    "dev": "nodemon index.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "cors": "^2.8.5",
    "express": "^4.17.2",
    "nodemon": "^2.0.15",
    "socket.io": "^4.4.1"
  }
}

When I push it to heroku and run it I receive the error: enter image description here

This is my logs: enter image description here

I do not know why this error appears, I have tried researching for hours with no luck. Please help thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source