1:文件处理(fs)1-1:读取文件:fs.createReadStream('要读取的文件路径,包括完整的文件名');1-2:新建(写入输入)文件:fs.createwriteStream('Thepathandnameofthefiletobewritten(新文件的路径和名称)')1-3:读取文件:fs.readFile('文件名',function(){...})(异步);fs.readFileSync('filename',function(){...})(同步)2:文件压缩解压(zlib)2-1:文件压缩:zlib.createGzip()2-2:文件解压:zlib。createGunzip()上面两个方法的例子:3:模块系统的导入导出3-1:导出:3-1-1:单次导出:exports.functionname=function(){...你的操作...}exports.functionname=functionname3-1-2:单个文件中多个方法导出:如下:3-2:导入和使用:hello.js被main.js作为一个模块(module)引入,所有导出函数在hello.js中可以使用,在main.js中包含很多属性和方法),使用module.exports。4:全局变量4-1:全局变量4-1-1:__filename:当前执行脚本的文件名4-1-2:__dirname:表示当前执行脚本所在的目录。5:工具模块
