E
E
ettaluni2021-02-24 13:39:31
Node.js
ettaluni, 2021-02-24 13:39:31

Why require the second call returns an object and not a class?

Good day! There is the following structure of modules:
60362c2865270089122637.png
Module1 acts as the main one, Module2 and Module3 are children, BUT the child modules also recuar each other.
The problem is, in the main module, requare normally connects the child module and returns the class. In the children (apparently the second time) it returns some kind of object.
I read that requare works like requare once and caches everything. Why doesn't it return a class to me, but some kind of object?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lynn "Coffee Man", 2021-02-24
@ettaluni

Cyclic addiction is bad. Get rid of her.
https://nodejs.org/api/modules.html#modules_cycles

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question