What is the purpose of Node.js module.exports and how do you use it?
What is the purpose of Node.js module.exports and how do you use it?
I can't seem to find any information on this, but it appears to be a rather important part of Node.js as I often see it in source code.
According to the Node.js documentation:
module
A reference to the current
module
. In particularmodule.exports
is the same as the exports object. Seesrc/node.js
for more information.
But this doesn't really help.
What exactly does module.exports
do, and what would a simple example be?