When I try to remove an existing directory (and its files inside) with fs.rm('./temp/', { recursive: true, force: true });
it succesfully remove it but it throws this error:
node:internal/fs/rimraf:60
callback(err);
^
TypeError: callback is not a function
at CB (node:internal/fs/rimraf:60:5)
at FSReqCallback.oncomplete (node:fs:188:23)
I have Node v16.13.2 installed. Thanks!
due to the node.js fs documentation https://nodejs.org/api/fs.html#fsrmpath-options-callback
you must pass a callback function
fs.rm(path[, options], callback)
so your code will look like this:
fs.rm('./temp/', { recursive: true, force: true }, (error) => {
//you can handle the error here
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With