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