Node.js fs.writeFileSync() Method
The fs.writeFileSync() method is a synchronous method. It creates a new file if the specified file does not exist. Also, the ‘readline-sync’ module is used to enable user input at runtime....
read more
Node JS fs.readFile() Method
In Node.js, the fs (File System) module furnishes a collection of methods for interacting with the file system. Among these methods, fs.readFile() stands out as a fundamental tool for reading data from files asynchronously. This article will delve into the fs.readFile() method, exploring its syntax, parameters, usage, and error handling....
read more
Node JS fs.writeFile() Method
fs.writeFile() method is used to asynchronously write the specified data to a file. By default, the file would be replaced if it exists. The ‘options’ parameter can be used to modify the functionality of the method....
read more
Node.js fs.readdirSync() Method
The fs.readdirSync() method is used to synchronously read the contents of a given directory. The method returns an array with all the file names or objects in the directory. The options argument can be used to change the format in which the files are returned from the method....
read more
Node.js fs.readdir() Method
The fs.readdir() method is used to asynchronously read the contents of a given directory. The callback of this method returns an array of all the file names in the directory. The options argument can be used to change the format in which the files are returned from the method....
read more
Node path.resolve() Method
The path.resolve() method is used to resolve a sequence of path segments to an absolute path. It works by processing the sequence of paths from right to left, prepending each of the paths until the absolute path is created. The resulting path is normalized and trailing slashes are removed as required.If no path segments are given as parameters, then the absolute path of the current working directory is used....
read more
Node.js fs.createReadStream() Method
The createReadStream() method is an inbuilt application programming interface of fs module which allow you to open up a file/stream and read the data present in it.Syntax:...
read more
Node.js fs.createWriteStream() Method
The createWriteStream() method is an inbuilt application programming interface of fs module which allows to quickly make a writable stream for the purpose of writing data to a file. This method may be a smarter option compared to methods like fs.writeFile when it comes to very large amounts of data....
read more
Node fs.copyFile() Function
The fs.copyFile() method is used to asynchronously copy a file from the source path to the destination path. By default, Node.js will overwrite the file if it already exists at the given destination. The optional mode parameter can be used to modify the behavior of the copy operation....
read more
Node fs.mkdir() Method
The fs.mkdir() method in Node.js is used to create a directory asynchronously....
read more
Node fs.appendFile() Function
The fs.appendFile() method is used to asynchronously append the given data to a file. A new file is created if it does not exist. The options parameter can be used to modify the behavior of the operation....
read more
Node fs.existsSync() Method
The fs.existsSync() method is used to synchronously check if a file already exists in the given path or not. It returns a boolean value which indicates the presence of a file....
read more