Node.js fs-extra remove() Function Last Updated : 15 Feb, 2022 Comments Improve Suggest changes Like Article Like 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 Comment More infoAdvertise with us Next Article Node.js fs-extra remove() Function P pritishnagpal Follow Improve Article Tags : Technical Scripter JavaScript Web Technologies Node.js Technical Scripter 2020 NodeJS-fs-extra +2 More Similar Reads Node.js fs-extra move() Function The move() function moves a file or a directory from source to the destination specified by the user. If you want to move a file to a folder in which a file with the same name already exists, the function will overwrite the file if we have set the option of overwrite to true else it will throw an er 3 min read Node.js fs-extra outputJson() Function The outputJson() function writes an object to the JSON file. If the user wants to write data onto a file that doesn't exist it will be created by the function itself. outputJSON() can also be used in place of outputJson(). Syntax: fs.outputJson(file,object,options,callback) or fs.outputJSON(file,obj 3 min read Node.js fs-extra pathExists() Function The pathExists() tests whether the given file path exists or not. It uses the fs.access() under the hood. Syntax: fs.pathExists(file,callback) Parameters: This function accepts two parameters as mentioned above and described below: file: It is a string that contains the file path.callback: It will b 2 min read Node.js fs-extra emptyDir() Function The fs-extra is a module that adds file system methods that are not included in the native fs module. It also adds promises support to the fs method. Some file system methods are not included in the native fs module, therefore, they have to be installed separately if we need to use them but the fs-e 3 min read Node.js fs-extra ensureFile() Function The ensureFile() function makes sure that the file user is requesting exists. If the file doesn't exist the function will create a new file. Even if the user is requesting a file that is inside some directory, but if the directory does not exist the function will create the directory and the file in 3 min read Like