How can I pass a variable while using `require` in node.js?

I think what you want to do is:

var user = require('./user')(client)

This enables you to have client as a parameter in each function in your module
or as module scope variable like this:

module.exports = function(client){

 ...

}

Leave a Comment