I have had a stupid question on my mind for a while:
How does require("moduleName") work?
I understand that if I have a file moduleA.js in my project, I could load the module using require("./moduleA"). But for many "well-known libraries" such as express, lodash, etc, I don't need to explicitly write the relative path in which the is library located. Instead I just use the module name (e.g. require('lodash');). My question is: how does that work? How can I make my own module work in that way, where the module can be loaded globally without writing the path(e.g. require('moduleA')).
Thanks