Open In App

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.

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
Article Tags :