We only need to know three points to know the difference between exports and module.exports:
1.exports is a reference to module.exports
2. The initial value of module.exports is an empty object {}, so the initial value of exports is also {}
3.require() returns module.exports instead of exports
so:
• We pass
var name ='nswbmw'; exports.name = name; exports.sayName =function(){ console.log(name); } Assigning a value to exports is actually adding two attributes to the empty object module.exports The above code is equivalent to:
var name ='nswbmw'; module.exports.name = name; module.exports.sayName =function(){ console.log(name); }The above article deeply understands the difference between node exports and module.exports is all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.