As said, do not use nested functions like that. Put them outside at module level, without exports them.