Node.js / Delete content in file

前端 未结 2 1360
走了就别回头了
走了就别回头了 2021-02-03 17:30

I want to delete the content of a simple text file with node.js. Or replace the file with a new/empty one.

How can I achieve this in node?

2条回答
  •  走了就别回头了
    2021-02-03 17:52

    fs.unlink is the call you need to delete a file. To replace it with different contents, just overwrite it with fs.writeFile.

提交回复
热议问题