DEV Community

Cover image for module.exports v/s exports - Clearing the confusion

module.exports v/s exports - Clearing the confusion

comscience profile image kapeel kokane ・1 min read

If you are one of those developers who spends majority of their time writing code in Node & Express, you might understand what I am talking about.

It's all well and good, you have written your code and now you want to use it in another file. You use module.exports this time and it works like a charm.

Next time around, you see an example wherein the "exports" variable is being used to do the same and you follow it. Works well this time too.

But then, once in a while, you try to assign something to the exports global that you are trying to export out of the file and it does not seem to work and you are now confused. This video tries to clear some of that confusion:

Discussion (0)

Forem Open with the Forem app