Exporting an anonymous module
Here’s an example of exporting an anonymous (no name!) function.
// eam.js
module.exports = function () {
console.log('Hello, eam!');
}
// app2.js
var eam = require('./eam.js');
eam();
- Create the two files above and then run
node app2.jsin the terminal. What do you see? - Update
eam.jswith some of your own code. - What happens if you add another
module.exportsafter the first one?