Node.js: how to get core module source
It is possible to ask node to show its core module source.
For example, we want to check the source of the readFileSync() method:
$ node
> fs = require('fs');
> fs.writeFileSync('fs.js', fs.toString())
> fs.writeFileSync('fs.readFileSync.js', fs.readFileSync.toString())
[Ctrl-C][Ctrl-C]
Now check the fs.readFileSync.js file in the current folder.
Also, on some systems, the source code of core node modules is in /usr/lib/nodejs/.
And another (less interesting) way to get the core module source is to look for it in the node GitHub repository: