In my Node application I need to remove a directory which has some files, but fs.rmdir
only works on empty directories. How can I do this?
33 Answers
As of Node.js 14.14.0, the recommended way is to use fs.rmSync
:
fs.rmSync(dir, { recursive: true, force: true });