Node Js Module Methods
Node Js Module Methods
path module
FS module
File System
The fs (File System) module in Node.js provides an API for interacting with the
file system. It allows you to perform operations such as reading, writing,
updating, and deleting files and directories, which are essential for server-side
applications and scripts.
print "data"
})
fsMode.unlink("filename", (err)=>{
if(err)
{
action
}
});
------------
appendFile() :- this method is used to add new content to the existing file.
Parameters:
path: It holds the name of the file to read or the entire path if stored at other
locations.
flags: Flags indicate the behavior of the file to be opened. All possible values
are ( r, r+, rs, rs+, w, wx, w+, wx+, a, ax, a+, ax+).
mode: Sets the mode of file i.e. r-read, w-write, r+ -readwrite. It sets to default
as readwrite.
err: If any error occurs.
data: Contents of the file. It is called after the open operation is executed.
------------------------------------------------------
exists() :- this method allows to check weather a file / folder is exist or not.
fsMod.exists(filename, (info)=>{
based on info check file
});
-----------------------
prompt-sync :- this module is used to read data from keyboard. it is a third party
module so that it has to install it.
npm install prompt-sync
fsMod.mkdir(foldername, (err)=>
{
action
});
------------