Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

161
Vistas
Is module.exports the same as export

Lets say you are building a npm library and you would like to export your functions.Like so:

function a(){

}

And now you want to export them. A way to do that locally would be:

export function a(){

}

But you could do it like this:

function a(){

}
module.exports = a;

Whats the difference? Do they do the same thing?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

no it's not the same,

module.exports is cjs syntax while import/export is modern esm syntax

cjs is older than esm, so the later is preferrable

with cjs you use require to import it

In the end if you write modern es6 javascript always use esm

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda