I have two different modules that need to require each other. I understand it creates an infinite loop and can't work. Is there a way to circumvent it?
Node.js allows circular require (see here). So most likely the infinite loop that is causing the error is a recursive function call (A calls B calls A ...) that never ends. Make sure that all functions complete finitely.
You can change one module to a proxy.
It's likely one of the modules doesn't immediately need the other one. If you pass in a proxy you can use it to get the dependency at a later time (like just-in-time).