Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

153
Views
Heroku gets wrong filepath for index.js

I tried to start my discord bot via heroku and it didn't start, when i checked the logs it gave me this response

Starting...
internal/modules/cjs/loader.js:905
throw err;
^

Error: Cannot find module 'Discord.js'
Require stack:
- /app/index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:93:18)
at Object.<anonymous> (/app/index.js:3:29)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/app/index.js' ]
}

To me it seems like it tries to start the index.js file through the filepath /app/index.js but the file is not located in /app/index.js but instead just /index.js and I never even entered anything about the /app filepath anywhere so I dont know why it does this

Edit: I realised that the logs didnt show anything useful ton search because I entered the logs too late and if I entered them earlier I would see more info about the error. Heres what it said earlier

at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/app/index.js' ]
}
Process exited with status 1
State changed from up to crashed
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

The issue is probably located in the package.json file because there is a field called main there which defines where your main file is located.

{
    "name": "lhubot",
    "version": "2.2.6",
    "description": "",
    "main": "index.js",
    ...
}
about 4 years ago · Juan Pablo Isaza Report

0

I found a answer myself, i wrote the wrong name for discord.js in require('discord.js'). I wrote "Discord.js" instead of "discord.js". Not sure why heroku found it as a problem but it was fine when i ran it on my own computer but that was the solution for me.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!