how to delete a directory in node js code example
Example 1: delete dir nodejs
fs.rmdirSync(dir, { recursive: true });
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
})