Delete a not empty folder with Node
Hi everyone I hope you are well.
I noticed that with Node it is possible to use functions related to the file system, including deleting a folder.
Unfortunately it is possible to use this function only with empty folders, do any of you know how to delete a folder that contains files?
Thank you all
make a recursive function to delete all the files in the folder, then delete the folder...
do you have an example?
thanks!
If you don't mind installing an npm package, you can use del
https://github.com/sindresorhus/del
Otherwise there are solutions out there:
https://stackoverflow.com/questions/12627586/is-node-js-rmdir-recursive-will-it-work-on-non-empty-directories/12761924#12761924