var fs = require("fs"); var readme = fs.readFileSync("readMe.txt", "utf-8"); //同步读取 var writeme = fs.writeFileSync("writeMe.txt", "写入!"); //同步写入 console.log(readme); var readme = fs.readFile("readMe.txt", "utf-8", function (err, data) { //异步读取 fs.writeFile("writeMe.txt", "写入!", function () { //异步写入 console.log("writeme has finished") }) }) console.log("finish")