1

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

2 Answers 2

1

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",
    ...
}
Sign up to request clarification or add additional context in comments.

2 Comments

"I will be using answers to reply because I don't have enough reputation to add comments yet"—please don't do this.
Thanks so much for your input @Chris . I knew "I will be using answers to reply because I don't have enough reputation to add comments yet" was bad but did not know it was that bad. On the other hand did not know posting text screenshots was forbidden, won't do that again. I fixed both answers now.
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.