nodejs 创建目录 创建文件
saveTmpTxt(name='tmp.txt', text){ var fs = require('fs'); let path = `${__dirname}/tmp`; // 创建临时目录 if(!fs.existsSync(path)){ fs.mkdirSync(path); } fs.writeFile(`${path}/` + name, text, function(err) { if(err) { return console.log(err); } console.log("The file was saved!"); }); }