Node module.exports returns undefined

后端 未结 3 2049
滥情空心
滥情空心 2021-01-19 00:55

I am having an issue with Node.js and module.exports. I understand that module.exports is a call to return an object, that object having whatever p

3条回答
  •  情话喂你
    2021-01-19 02:01

    module.exports = Format;
    

    This will return the Format constructor when you will require('./formatting')

    On the other hand the code below will return an instance of Format, which you can directly call methods on:

    module.exports = new Format();
    

提交回复
热议问题