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.onplete (node:fs:188:23)
I have Node v16.13.2 installed. Thanks!
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.onplete (node:fs:188:23)
I have Node v16.13.2 installed. Thanks!
Share Improve this question edited Jan 25, 2022 at 11:37 La-lo-go asked Jan 25, 2022 at 11:12 La-lo-goLa-lo-go 3002 silver badges13 bronze badges1 Answer
Reset to default 9due to the node.js fs documentation https://nodejs/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
});