When you require npm modules, you just write require('package name'). You don't specify path like require('../path/to/package'). So, I guess it scans the node_modules in root directory which brings me to the next question : what if there is already a node_modules folder in the innermost directory from where I am requiring.
Any insights will be useful.
Thanks.
Jon
ClojureScript Developer.
I think this is a common question back to the time Node.js was going trend, so just Google and you will find a lot. Also reading source code will help since it's in JavaScript.
So in CommonJS the "require" looks up modules in current directory and parent directories. It will scan the innermost directory first, if not found, it goes to the parent directory, and repeats until found of failed.