i

File System Module

For executing file operations, Node comes bundled with fs module.

fs module provides API for interacting with the file system, which is modeled around POSIX functions. All File system operation provided by fs is in synchronous as-well-as asynchronous form.

It is recommended using asynchronous functions.

fs module can be imported  in your application for using File System operations.

It also provides support for URL objects.

const fs=require('fs')

same directory.

We used readFile function provided by the fs module. This function reads the file in an Asynchronous manner.

Fs-demo.js

Output on running the above code using

>Nodemon fs-demo.js

Similarly, we have readFileAsync function, which does the same operation as readFile but synchronously.

We have other operations like writeFile, opening the file, rename file, etc. which we are not discussing