Open In App

Node.js fs-extra remove() Function

Improve
Improve
Like Article
Like
Save
Share
Report

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

Last Updated : 15 Feb, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads