exports只能抛出对象,而module.exxports可以抛出当前内容形式(数组,,对象,字符串,方法....)
module->当前模块 包含当前模块的一些信息(module.id,module.filename,module.parent,module.children.module.loaded,module.exports)
当调用require方法引入模块时,实则引入的是当前模块的module.exports属性值,
Node为每个模 提供了一个exports变量,而这个变量指向module.exports,如果直接给exports赋值,
相当于切断了与 moudule.exports的联系,此时exports变量将不再指向moudule.exports的属性。
所以我们可以简单的理解为:
- module.exports 初始值为一个空对象 {}
- exports 是指向的 module.exports 的引用
- require() 返回的是 module.exports 而不是 exports
- exports是module.exports的一个变量