Nodejs app fails to deploy on Heroku - Application error - Error: Cannot find module './Utilities'

26 views Asked by At

I am new to nodejs. I've been trying to deploy my node.js app to Heroku, but it keeps failing. My node version is 16.14.2. In the logs, it says Error: Cannot find module './Utilities. I have no idea what it is. However, it was deployed successfully, but when I open the app, it says Application Error Please help! Thank you

index.js file:

const express = require("express");
const cors = require("cors");
const app = express();
require("dotenv").config();
const {AnimeData} = require("@dovakiin0/anime-data");
const anime = new AnimeData();
const {Client} = require("anilist.js");
const AniList = new Client("eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImY2MTAxNTRlYzM4MTMxN2FmYTAxYWUzYTI3NzI2OWZmYzg0ZDMyYmUzZGFlMWE0ZjMxY2VlZjJlZTIyMDgyZmY2YmNkYTVlMmVkZTMxNzQ5In0.eyJhdWQiOiI4NTM0IiwianRpIjoiZjYxMDE1NGVjMzgxMzE3YWZhMDFhZTNhMjc3MjY5ZmZjODRkMzJiZTNkYWUxYTRmMzFjZWVmMmVlMjIwODJmZjZiY2RhNWUyZWRlMzE3NDkiLCJpYXQiOjE2NTQ4NzEwMTksIm5iZiI6MTY1NDg3MTAxOSwiZXhwIjoxNjg2NDA3MDE5LCJzdWIiOiI1ODg5ODk0Iiwic2NvcGVzIjpbXX0.IbHJOfU_cJn4v61rzB-41hq_c4Uy0D2NQ27p9aW5wiY1DYu6BijYZZ9n-BqR3Vu3I-uTFE7NTDxFuOpi8agQ1DlnDNNZNls5CqDZeqw-bbuD1D4K7-KXwAKSxSOtM3_zZaQU4rRMTaIGA5ornHRybvx9p0TziASNNCBX3Jp5pDTX1xF-QASHzYyzfAMDIGq-9F7MDc6uKr1M4AivGAWq8neUwaClLtjD6iImkztdtBrUtkmrcLxoP27Q8AOehg1uQNtLpFZDh0rJZPMfy6iefS58pF9Wc-QWzDZ610OezynlmDDwBOA2uFfaclLgtYlseCxf1v9ZhS9rsg9MVC_I3juZgPn0nvcMMBZqaUcFtcj8a2cnnkWAIR9b5TYbUxarVWNRYRgKVEho0NUY_ABBqK0jrqw0TwhPYH6DPQXlzDD5NmmUMA3ulT_vdRZ7hH3sUh8B0L5EbtYwfHcHVSE6Nc3uJ-FNbsOL2M3rLic4t6S34b64XZz7DunIy8x9gjdCXT5raHkdHrk3kVrfLG6lZGe_XHH3XsV04zdA6BwY1d5Zbr5pYZRSu6NupMNuyqaUsLTCga0ZfluOqHiF8R9fSyIOQZGCk7sMYFm76o71BhGguDMT8ePEuxyg2G0K2qzmw1t3H21vKcjD08ltq522wo6849cr21FWi_pJOXiKVds");

const port = process.env.PORT || 5001
app.use(express.urlencoded({extended: true}));
app.use(cors());
app.use(express.json());

app.post("/watch", (req, res)=> {
  anime
      .searchAnime(req.body.title)
      .then((result) => {
        // list of anime that matches the search
        anime.getAnimeInfo(result[0].link).then((info) => {
        // Anime details
          anime.getEpisode(info.slug, req.body.episode).then((episode) => {
          // gets the specific episode of the anime
            res.send(episode);
          });
        });
      })
      .catch((err) => {
        res.send(err);
      });
});
app.post("/anilist", (req, res) =>{
  AniList.searchMedia({search: req.body.title})
      .then((data)=>{
        res.send(data);
        console.log(data)
      })
      .catch((e) => {
        res.send(e);
      });
});
app.listen(port, () => {
    console.log(`listening on port ${port}...`)
})

package.json

{
  "name": "medianime",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node index.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@dovakiin0/anime-data": "^1.6.3",
    "anilist.js": "^1.2.1",
    "cors": "^2.8.5",
    "dotenv": "^16.0.1",
    "express": "^4.18.1"
  },
  "engines": {
    "node": "16.14.2"
  }
}

Procfile:

web: node index.js

.gitignore:

/node_modules
npm-debug.log
.DS_Store
/*.env
0

There are 0 answers