Delete a file asynchronously:
var fs = require('fs');
fs.unlink('/path/to/file.txt', function(err) {
if (err) throw err;
console.log('file deleted');
});
You can also delete it synchronously*:
var fs = require('fs');
fs.unlinkSync('/path/to/file.txt');
console.log('file deleted');
* avoid synchronous methods because they block the entire process until the execution finishes.