I am trying to organize a Node.js application developed with Express 4 and am confused about the scope of modules which are imported with require().
Imagine that I use require('./services/user')
to import a service in a module such as routes/user.js:
var userService = require('./services/user');
Then I do the same require('./services/user')
in another module routes/department.js.
My question is: is userService the same instance in user.js and department.js or each of them has it's own userService object? That is to say, once you've exported some element through module.exports = XXX if you require the same file, will you get always the same instance? Could you show me where in the Node.js docs that's specified?