关于NodeJs中writeFile保存含有格式的Js文件


import fs from "fs";

const mapContent = `export default ${JSON.stringify(xxxxx, null, "\t")}`;
fs.writeFile("./xxxxx.js", mapContent, (err) => {
  if (err) throw err;
  console.log("写入成功");
});