fs.readdir(dir, (err, files) => { if(err) throw err; for(const file of files) { fs.unlinkSync(path.join(directory, file)); } });