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?
As of Node.js 12.10.0, fs.rmdirSync
supports a recursive
options, so you can finally do:
fs.rmdirSync(dir, { recursive: true });
Where the recursive
option deletes the entire directory recursively.