Friday, May 8, 2026
HomeLanguagesJavascriptNode.js fs-extra remove() Function

Node.js fs-extra remove() Function

the remove() function deletes the given file or directory. All the files inside a directory are deleted. If the given file or directory does not exist the function will do nothing.

Syntax:

fs.remove(path,callback)

Parameters: This function accepts two parameters as mentioned above and described below.

  • path: It is a string that contains the file path or directory path.
  • callback: It will be called after the function is executed. We can use promises in place of the callback function as well.

Return value: It does not return anything.

Follow the steps to implement the function:

The module can be installed by using the following command:

  •  
npm install fs-extra

After the installation of the module you can check the version of the installed module by using this command:

  •  
npm ls fs-extra

Create a file with the name index.js and require the fs-extra module in the file using the following command:

  •  
const fs = require('fs-extra');

To run the file write the following command in the terminal:

  •  
node index.js
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32514 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6892 POSTS0 COMMENTS
Nicole Veronica
12012 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12106 POSTS0 COMMENTS
Shaida Kate Naidoo
7016 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6975 POSTS0 COMMENTS
Umr Jansen
6962 POSTS0 COMMENTS