How to remove all files from directory without removing directory in Node.js

How to remove all files from a directory without removing a directory itself using Node.js?
I want to remove temporary files. I am not any good with filesystems yet.

I have found this method, which will remove files and the directory. In that, something like /path/to/directory/* won’t work.

I don’t really know what commands should use. Thanks for the help.

76 thoughts on “How to remove all files from directory without removing directory in Node.js”

Leave a Comment