Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

150
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda