You shouldn't execute the function in your exports statement (the msg
argument will be undefined
which indeed is not a string or a buffer):
exports.util = {
...
myHash: myHash, // don't use myHash()
...
};
Also, when you export your code like this, you have to require it like this:
GLOBAL.util = require('./util').util;
(although I would suggest not using globals).
If you don't want the extra .util
, export like this:
module.exports = {
...
myHash : myHash,
...
};