I have created a node.js module which contains method a
with optional recursive calls. Simplified structure:
module.exports = {
a() {
// ...
if (condition) {
a();
b();
}
// ...
}
b() {
//...
}
}
After importing this module with const { a } = require(path)
calling a
with arguments that cause condition
to be false works perfectly.
However, when a
is called recursively, a ReferenceError is raised with message "a
is not defined".
Changing the recursive call to this.a() seems to fix the original problem, however now the same error is being raised for b, with and without this in front of it.
How can I fix this?