Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

722
Views
TypeError: callback is not a function when removing directory

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!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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
});
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!