As modular application composition is The Node Way, you will often see (and use) the require statement. You will have noticed that the argument passed to require can take many forms, such as the name of a core module or a file path.
The following pseudocode, taken from the Node documentation, is an ordered description of the steps taken when resolving module paths:
// require(X) from module at path Y
REQUIRE(X)
1. If X is a core module,
a. return the core module
b. STOP
2. If X begins with '/'
a. set Y to be the filesystem root
3. If X begins with './' or '/' or '../'
a. LOAD_AS_FILE(Y + X)
b. LOAD_AS_DIRECTORY(Y + X)
4. LOAD_NODE_MODULES(X, dirname(Y))
5. THROW "not found"
LOAD_AS_FILE(X)
1. If X is a file, load X as JavaScript text. STOP
2. If X.js is a file, load X.js as JavaScript...