2

AFAIK, module.exports and exports are available through hidden arguments available to any file via a wrapping function and point to the same object in node.js.

If I do this:

exports.foo = 'foo';
  module.exports.bar = 'bar';

both foo and bar will be accessible to the file that imports it.

Also, I can do this:

 module.exports = ()=>{}

But I can't do this:

 exports = () =>{}

Why's that? If one is allowed to be overridden so should be the other as both point to the same object. What am I missing?

ABGR
  • 4,631
  • 4
  • 27
  • 49
  • 1
    Does this answer your question? [module.exports vs exports in Node.js](https://stackoverflow.com/questions/7137397/module-exports-vs-exports-in-node-js) – bigless Jul 20 '20 at 19:46
  • @bigless Went though this. But I'm still trying to wrap my head around why one is allowed to be overridden while the other is not when both points to the same object? – ABGR Jul 20 '20 at 20:09

0 Answers0