Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

162
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!