What is a File System ?

skillsyard fs-module

The fs module in Node.js is a in-built module that allows you to work with both files and directories in a variety of ways, such as reading, writing, updating, deleting, and navigating the file system.

How to include fs to your code ?

  • To initialise the File System we use require() method;
  • fs module syntax
  • it will return file system object and we can store that in a variable , for example const fileObject = require('fs');
  • Example:

    file system example
  • The returned fileObject contains many methods to manipulate files in a device.
  • Some of them are :

  • fileObject.writeFile()
  • fileObject.writeFileSync()
  • fileObject.readFile()
  • fileObject.readFileSync()
  • fileObject.unlink()
  • fileObject.unlinkSync()
  • fileObject.rename()
  • fileObject.renameSync()
  • Summary:

    File System is a in-built Nodejs module which let us to create , update and change in files in our directories/folders.