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

125
Visualizações
why both exports and module.exports used in main module of express (express.js file)

i read this stackoverflow question and this one, and other internet searches. the summery of my search is module.exports and exports point to same object that will be exported and those exports are accessible with require(<package identifier> or <JS file identifire>). because the parameter passing strategy in the JS is call-by-sharing if we assign a function to module.exports the exports object is now useless.(because that exports still pointing to previous value of module.exports) i add this too from nodejs.com, require() function will give us exported variables and functions from main module of a package or a normal js file.

now the question is why in express.js file we have other things that are attached to exports while we assigned a function to module.exports?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

because in this line

exports = module.exports = createApplication;

these are pointing to same function and in js function are objects .

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