module.exports vs exports in Node.js

前端 未结 23 1247
自闭症患者
自闭症患者 2020-11-22 06:11

I\'ve found the following contract in a Node.js module:

module.exports = exports = nano = function database_module(cfg) {...}

I wonder what

23条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-22 06:53

    "If you want the root of your module's export to be a function (such as a constructor) or if you want to export a complete object in one assignment instead of building it one property at a time, assign it to module.exports instead of exports." - http://nodejs.org/api/modules.html

提交回复
热议问题