Deleting a file asynchronously using fs.unlink
method of fs
module
of node.js
//Name of the file : deletefile-async.js
var fs = require('fs');
var filename = 'assets/content.txt';
fs.unlink(filename, (err) => {
if (err)
throw err;
console.log('File deleted successfully');
});
>node deletefile-async.js
File deleted successfully