How to deal with cyclic dependencies in Node.js

后端 未结 13 1965
别那么骄傲
别那么骄傲 2020-11-22 04:36

I\'ve been working with nodejs lately and still getting to grips with the module system so apologies if this is an obvious question. I want code roughly like the following b

13条回答
  •  醉酒成梦
    2020-11-22 04:58

    One way to avoid it is to don't require one file in other just pass it as an argument to a function what ever you need in an another file. By this way circular dependency will never arise.

提交回复
热议问题