Frome reqire's docs:
Once Node.js finds the node_modules folder, it will then attempt to load the
given module either as a (.js) Javascript file or as a named sub-directory.
And, if it finds the named sub-directory, it will then attempt to load the file
in various ways. So, for example, if you make a request to load the module, "test":
var utils = require( "test" );
... Node.js will perform a hierarchical directory search for "node_modules"
and "test" in the following ways:
./node_modules/test.js
./node_modules/test/index.js
./node_modules/test/package.json
So, answer is: File first, Directory second, Module third.