Chapter 7. Wiring Modules
require() function (as we have seen in
Chapter 2, Node.js Essential Patterns), a simple yet powerful approach. However, many developers new to Node.js might find this confusing; one of the most frequently asked questions is in fact: what's the best way to pass an instance of component X into module Y?
Sometimes, this confusion results in a desperate quest for the Singleton pattern in the hope of finding a more familiar way to link our modules together. On the other hand, some ...