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.
1.4m articles
1.4m replys
5 comments
57.0k users