Simply declare it separately from exporting it (and don't use this
when calling it, you haven't attached it to an object):
function sayHello(msg) {
console.log(msg)
}
exports.sayHello = sayHello;
function run(msg) {
sayHello(msg);
}
run("hello");
That said, you could call it via exports
:
exports.sayHello = function (msg) {
console.log(msg)
}
function run(msg) {
exports.sayHello(msg); // <===
}
run("hello");
...but that seems a bit roundabout to me, though I'm told it can help with testing, such as in this example.