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

333
Visualizações
NODE [ERR_MODULE_NOT_FOUND]: Cannot find module './config/app'

FIXED, the names of the folders in my pc changed when uploaded to github

So, my app looks something like this

├── config
|    ├── app.js
|
└── index.js

app.js

Here i have all my env variables, so I have a central point from which to extract them

require('dotenv').config()

module.exports = {
    appPort: process.env.PORT,
    appUrl: process.env.APP_URL,
    appKey: process.env.APP_KEY,
    frontendUrl: process.env.FRONTEND_URL
}

index.js

central file of the server

const express = require('express')
const cors = require('cors')
const app = express()

const { appPort, frontendUrl } = require('./config/app')

app.listen(appPort , () => {
    console.log(`Server listening on port ${appPort}`);
})

The problem here is that when i deploy it and starts the server, it throws me error

node:internal/modules/cjs/loader:936
   throw err;
   ^
 
 Error: Cannot find module './config/app'
 Require stack:
 - /app/index.js
     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
     at Function.Module._load (node:internal/modules/cjs/loader:778:27)
     at Module.require (node:internal/modules/cjs/loader:1005:19)
     at require (node:internal/modules/cjs/helpers:102:18)
     at Object.<anonymous> (/app/index.js:8:34)
     at Module._compile (node:internal/modules/cjs/loader:1103:14)
     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
     at Module.load (node:internal/modules/cjs/loader:981:32)
     at Function.Module._load (node:internal/modules/cjs/loader:822:12)
     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
   code: 'MODULE_NOT_FOUND',
   requireStack: [ '/app/index.js' ]
 }

and i really don't know why, because it works perfectly fine in my pc

the code for the whole project is actually much bigger, but only this files are the ones throwing me errors

Hope someone can help see what is happening that throws that error

about 4 years ago · Santiago Gelvez
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