I had my custom module with following code:
module.exports.PrintNearestStore = async function PrintNearestStore(session, lat, lon) {
...
}
Error with first case: PrintNearestStore - Function expression, so this name not available outside.
error with second case: using variable, instead Function declaration. In this case, declaration of variable PrintNearestStore are hoisted, so, you can use this name before line var PrintNearestStore = ..., but in this case value would be undefined.
So, simplest solution change second variant like this:
module.exports.PrintNearestStore = PrintNearestStore;
async function PrintNearestStore(session, lat, lon) {
}