DEV Community

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

Posted on

module.exports v/s exports - Clearing the confusion

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:

https://www.youtube.com/watch?v=Bj1v1Yfg5TU

Top comments (0)