http://stackoverflow.com/questions/7137397/module-exports-vs-exports-in-node-jshtml
其中推薦回答:node
http://www.hacksparrow.com/node-js-exports-vs-module-exports.htmlui
module.exports
is the real deal. exports
is just module.exports
's little helper. Your module returns module.exports
to the caller ultimately, not exports
. All exports
does is collect properties and attach them to module.exports
IF module.exports
doesn't have something on it already. If there's something attached to module.exports
already, everything on exports
is ignored.spa
exports只是做爲helper,exports作的僅僅是收集module.exports所沒有的屬性並把它們掛在到module.exports上,若是module.exports已有某屬性,exports的該屬性會被直接忽略。code
As long are you don't overwrite the module.exports
object with an assignment operation, anything attached to module.exports
and exports
will be available in the 'required' module.htm
只要你不用賦值符號(=)重寫module.exports
對象,任何掛在到module.exports
and export的屬性在required的模塊裏都是可用的。
對象