When you define module.exports
as myFunc
, you are defining the export object to be the function itself, but you were expecting the function to be a part of the object. The following would be correct:
console.log(test2());
Alternatively, define the function as a part of the export but not the export itself.
module.exports = {myFunc};