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?
There is a module for this called rimraf
(https://npmjs.org/package/rimraf). It provides the same functionality as rm -Rf
Async usage:
var rimraf = require("rimraf");
rimraf("/some/directory", function () { console.log("done"); });
Sync usage:
rimraf.sync("/some/directory");