If you look at the sources of passport-local
index.js
you'll see it exports the same thing directly and in exports.Strategy
.
When you do require('passport-local).Strategy
you import the export defined in exports.Strategy
, but it's really the same to do just require('passport-local')
in this case because the same constructor is exported directly from the module.
If you define a module like this:
var Thing = { foo: () => 'bar' };
exports = module.exports = Thing;
exports.Thing = Thing;
you can use it in many ways:
const Thing = require('./module');
console.log(Thing.foo());
works, as does
const Thing = require('./module').Thing;
console.log(Thing.foo());
and with both imports you can actually call also
console.log(Thing.Thing.foo());
If you remove the exports.Thing = Thing;
part of the module, then
const Thing = require('./module').Thing;
does not work anymore.
The exports cause confusion often. You could take a look of Node docs or eg. this answer.