There are several canonical ways to handle this. None of them, in my opinion, were particularly excellent. (Node really needs to support the actual replacement of the temporary object in the original context by the exported object in cyclical situations. The benefits are worth doing some ugly hacker V8 cheaters, IMO./rant)
Late construction
You may have a higher-level module, perhaps an input module to your library, prepare the final configuration of interdependent things:
Awful because:. Now you have focused on the higher-level module and removed this installation code from the context in which it makes sense (and in which, we hope, it will remain.) A great way to watch how everything goes out of sync.
Dependency Inclusion
We can improve this by moving the setting back to the care of each individual submodule and excluding dependency management in a higher-level file. Dependencies will be obtained by a module of a higher level (without cycles), and then will be passed as necessary:
It's terrible because: Well, besides the fact that it is absolutely ugly in this particular scenario (!!?!), You just pushed the problem of solving the problem-dependency to the consumer stack. In this situation, this consumer is still himself, which works well ... but what happens when you want to expose A only through require('my_library/a') ? Now you need to document the consumer that they should parameterize your submodules with dependencies X, Y and Z ... and blah, blah, blah. Down the rabbit hole.
Incomplete classes
So, to repeat the above, we can abstract some of these consumer dependency disorders by implementing them directly in the class (thereby preserving local problems as well):
It's terrible because: Unfortunately, this still adds some conceptual overhead for your API: "Be sure to always call A.finish() before using A !" may not match your users. Likewise, this can cause obscure, hard-to-maintain error dependencies between your submodules: now A can use elements of B ... except for parts of B that depend on A. (And which parts are likely to remain unobvious during development.)
Allow circular dependencies
I cannot write this part for you, but it is the only ugly solution; and this is canonical, some Node programmer will come to you if you bring them this question. I presented the above assumptions about stack overflow that you know what you are doing (and you have every reason for cyclic dependencies, and removing them would be nontrivial and more detrimental to your project than any of the above) ... but in all reality, the most likely situation is that you just need to redesign your architecture to avoid circular dependencies. (Yes, I know this advice sucks.)
Good luck (=