--fs
require('fs')
fs.readFile(filename, [encoding], [callback(err,data)])
When content encoding is not set, it will be output in buffer format
Receive parameters:
filename file path
options option object, including encoding, encoding format, this item is optional.
callback callback, passing 2 parameters exception err and file content data
var fs = require('fs'); fs.readFile('2.js', 'utf-8', function (err, data) { if (err) { console.log(err); } else { console.log(data); } });
--path
require('path')
path.sep
path.extname()