Capitalization of modules in Node.js
Tradition in Node.js dictates you import core modules using this style:1
2var fs = require('fs');
fs.readFile(packageJSONPath, readOperationDidFinish);
I’ve adhered to that style for the most part, but it’s always rubbed me the wrong way.
As a core modules that points to a collection of static methods, capitalization is more appropriate.1
2var FS = require('fs');
FS.readFile(packageJSONPath, readOperationDidFinish);
Where the correct decision becomes most apparent is when using the path
module:1
2
3var Path = require('path');
var join = Path.join;
var path = join(process.cwd(), 'package.json');
We used lowercase for local values, and using lowercase for the path
module easily results in naming conflicts.