Node require returns undefined
A simpler explanation is that module.exports
is resolving to undefined
inside the module that you are requiring. Post the code of the failing modules.
It also happens if your require a module that is already included somewhere earlier in the code.
This statement is incorrect.
due to the asynchronous nature of node, the files are "not yet" required
require
is synchronous.
It is correct that if module A
requires B
, which in turn requires A
, then A
will be undefined
in module B
. But I'm not sure this is the problem.