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

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

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 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!