Join the AI Workshop and learn to build real-world apps with AI. A hands-on, practical program to level up your skills.
To remove all files from a directory in Node.js, use the fs-extra library.
Install it:
npm install fs-extra
Then import it:
import fsExtra from 'fs-extra'
Then use the emptyDirSync() method:
const folder = './public/images'
fsExtra.emptyDirSync(folder)