Node.js File System (fs) Module

The fs module in Node.js is used to work with files and folders.

Example

const fs = require("fs");

fs.writeFileSync("example.txt", "Hello from Node.js!");

console.log("File created successfully.");
        
Output:

File created successfully.
A file named example.txt is created.

Common fs Methods

← Back to Home