If you require a directory, require
will try to include a module from that directory based on these rules:
If X/package.json is a file,
a. Parse X/package.json, and look for "main" field.
b. let M = X + (json main field)
c. LOAD_AS_FILE(M)
2. If X/index.js is a file, load X/index.js as JavaScript text. STOP
3. If X/index.json is a file, parse X/index.json to a JavaScript object. STOP
4. If X/index.node is a file, load X/index.node as binary addon. STOP
Most likely you have a directory structure that looks like this:
module/
index.js
src/
file-including.js
This will load index.js
. You could also write it as require('../index.js')
or even require('../index')
and it would function the same.