I have two functions in the same file, both accessed externally. One of the functions is called by the second.
module.exports.functionOne = function(param) {
console.log('hello'+param);
};
module.exports.functionTwo = function() {
var name = 'Foo';
functionOne(name);
};
When this gets executed, the call to functionOne is flagged as not defined.
What’s the right way to reference it?
One pattern I’ve found to work is by referencing the file itself.
var me = require('./thisfile.js');
me.functionOne(name);
… but it feels like there has to be a better way.
Just simply
module.exports.functionOne().If that’s too cumbersome, just do the following: