Node.js中module.exports和exports
在Node.js中,导出一个对象可以用exports,也可以用module.exports,但是这两者是有些区别的。先看一个例子: 1234567891011//snippet-1:// foo1.jsexports.foo = "foo1";// foo2.jsmodule.exports.foo = "foo2";// bar.jsconsole.log(require('./foo1').foo); // Output: foo1console.log(require('./foo2').foo); // Output: foo2