I keep getting this problem in Node, where my application crashes when I call functions from each other.
I made this minimal working example (working as it gives me an error):
Run module
var module2 = require('./module2'); var data = 'data'; module2.doStuff(data);
Module2
var module3 = require('./module3'); function doStuff(data){
Module3
var module2 = require('./module2'); function takeStuff(data){
The error I get is:
module2.doSomethingElse(data); // I get the type error here ^ TypeError: undefined is not a function
start module calls a function in module2 , which ultimately calls a function in module3 , which in turn calls a function in module2 .
All modules are properly required, and it finds the first method in module2 just fine.
What happens here and how to do it if you need to get a function from the module that came with?
EDIT
Debugging shows me that the module exists, but it is empty except for the prototype that it has. Why is my question? Inside Node / JavaScript, what's going on here?
Gemtastic
source share