Node.js fs.opendir() Method
The fs.opendir() method is used to asynchronously open a directory in the file system. It creates an fs.Dir object that is used to represent the directory. This object contains various methods that can be used to accessing the directory....
read more
How to operate callback-based fs.readFile() method with promises in Node.js ?
The fs.readFile() method is defined in the File System module of Node.js. The File System module is basically to interact with the hard disk of the user’s computer. The readFile() method is used to asynchronously read the entire contents of a file and returns the buffer form of the data....
read more
Node.js fs.promises.appendFile() Method
The fs.promises.appendFile() method of File System module in Node.js is used to interact with the hard disk of the user’s computer. The appendFile() method is used to append new data into the existing file or if the file does not exist then file is created first and after that given data is appended to it. The fs.promises.appendFile() method returns a resolved or rejected promise and hence avoid the callback nesting or callback hell problems that may occur in fs.appendFile() method....
read more
Node.js fs.lstat() Method
The fs.lstat() method is similar to the fs.stat() method except that it is used to return information about the symbolic link that is being used to refer to a file or directory. The fs.Stat object returned has several fields and methods to get more details about the file....
read more
Node.js fs.link() Method
The fs.link() method is used to create a hard link to the given path. The hard link created would still point to the same file even if the file is renamed. The hard links also contain the actual contents of the linked file....
read more
How to return an array of lines from a file in node.js ?
In this article, we will return an array of lines from a specified file using node.js. The fs module is used to deal with the file system in node.js and to read file data we use fs.readFileSync( ) or fs.readFile( ) methods. Here we will use the readFileSync method to read the file, and we use the steps below to return the lines of the file in an array:...
read more
Node.js fs.realpath() Method
The fs.realPath() method is used to compute the canonical pathname of the given path. It does so by resolving the ., .. and the symbolic links in the path....
read more
Node.js fs.writeSync() Method
The file system module or fs module is an inbuilt module in Node js which is used to work with files on the computer. The functions of the module can be used by importing the fs module. The fs module can be included in the program by using the fs.writeSync() function of the filesystem module is the synchronous version of the write() method. It can be used for writing text as well as binary data onto the file....
read more
Node.js fsPromises.mkdir() Method
The fsPromises.mkdir() method is used to asynchronously create a directory then resolves the Promise with either no arguments, or the first directory path created if recursive is true....
read more
Node.js fs.mkdtemp() Method
The fs.mkdtemp() method is used to create a unique temporary directory. The folder name is created by appending 6 randomly generated characters behind a prefix string. It is also possible to create the temporary directory inside a folder by using a separator after the folder path....
read more
Node.js fs.mkdtempSync() Method
The fs.mkdtempSync() method is an inbuilt application programming interface of fs module which provides an API for interacting with the file system in a manner closely modeled around standard POSIX functions. The fs.mkdtempSync() method creates a unique temporary directory. This is the synchronous version of fs.mkdtemp() method....
read more
Node.js fsPromises.access() Method
The fsPromises.access() method is used to test the permissions of a given file or directory specified by path. The permissions to be checked can be specified as a parameter using file access constants. It is also possible to check multiple file permissions by using the bitwise OR operator to create a mask with more than one file constant....
read more