nodejs delete files in directory code example
Example 1: how to delete a folder using node js
fs.unlink('./node/myText.txt',function(){
fs.rmdir('node');
});
Example 2: how to delete everything from a folder in js
const fsPromises = require('fs').promises
// For ES syntax: import { promises as fsPromises } from 'fs'
const directory = 'your/directory/path/here'
await fsPromises.rmdir(directory, {
recursive: true
})