You're trying to use object syntax within a function. So either get your function to return your functions, or just use an object instead and export that. To pass in an argument you'll need something like an init function.
var obj = {
init: function (name) {
this.name = name;
return this;
},
func1: function () {
console.log('Hallo ' + this.name);
return this;
},
func2: function () {
console.log('Goodbye ' + this.name);
return this;
}
};
module.exports = obj;
And then just import it within another file using the init method. Note the use of return this - this allows your methods to be chained.
var variable = require('./getVariable'); // David
var obj = require('./testfile').init(variable);
obj.func1(); // Hallo David
obj.func2(); // Goodbye David