module.parent
in a node app refers to the parent module of the current module.
This is useful for getting paths (for example) relative to the parent, for example used internally in fileGetter:
// Should get localPath in ./, not localPath in ./lib/some-folder
var fileGetter = require("./lib/some-folder/file-getter.js");
var text = fileGetter("./localPath.dat");
The problem is that this usecase is effectively completely useless:
the file getter will get the path (using path.dirname(module.parent.filename)
) relative to the first module that requires file getter.
If the file getter is used several places in the application, the first require determines the path.
As a result, it is completely and utterly useless.
$ node example.js
User 1 <path>\user1.js
User 2 <path>\user1.js
Notice that these are identical (==user1.js). The guessing fails for user2.js because it was required second.