delete all childs in node

const fs = require('fs');

const directory = './yourdirectorypath/';

fs.readdir(directory, (err, files) => { if (err) throw err;

for (const file of files) { fs.unlink(${directory}${file}, err => { if (err) throw err; console.log(${file} was deleted); }); } });