0% found this document useful (0 votes)
7 views

Node Js

Uploaded by

hamdanhu23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Node Js

Uploaded by

hamdanhu23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Node JS

Node module system :-

● The Node.js module system is a fundamental part of the Node.js architecture, allowing
developers to organise their code into modular and reusable components. It helps in
maintaining clean and manageable codebases by breaking down the application into
smaller, more focused units.

❖ common methods provided by the fs module:

Reading Files

1. fs.readFile: Reads the entire contents of a file.


2. fs.readFileSync: Synchronously reads the entire contents of a file.

Writing Files

3. fs.writeFile: Writes data to a file, replacing the file if it already exists.


4. fs.writeFileSync: Synchronously writes data to a file, replacing the file if it already
exists.

Updating Files

5. fs.appendFile: Appends data to a file, creating the file if it does not exist.
6. fs.appendFileSync: Synchronously appends data to a file, creating the file if it does
not exist.

Deleting Files

7. fs.unlink: Deletes a file.


8. fs.unlinkSync: Synchronously deletes a file.

Working with Directories

9. fs.mkdir: Creates a new directory.


10. fs.mkdirSync: Synchronously creates a new directory.
11. fs.readdir: Reads the contents of a directory.
12. fs.readdirSync: Synchronously reads the contents of a directory.

You might also like