Is there a npm package that can empty the folder?

I don"t know if npm can have commands to empty folders, so that I can write to npm script

.

rimraf is specifically used to delete folders, but I don"t want to delete folders, but empty them. I don"t know if there is a npm that can use

.

if you have nodejs directly, please post the code

Mar.03,2021

if you just want to use the npm package, you can try fs-extra , it is based on the fs module to do a lot of packaging is expanded, the basic operation of the file can be satisfied, you mean to understand.

address: https://www.npmjs.com/package.
the method of emptying the folder you want. Refer to this: https://github.com/jprichards.

. < hr >

in fact, instead of npm package, you can solve it with a single Linux command.

$ rm -rf ./dirname
$ mkdir dirname

npm install empty-folder

rimraf

Menu