Node.js
/Beginner
File System (fs) Module
Definition
A core Node.js module used to interact with the hard drive. It provides functions to create, read, update, delete, and rename files and directories.
Explain Like I'm New
It's your application's hands. It allows Node to reach out of the code, grab a text file off your desktop, read what's inside, write a new line to it, and save it. It has three versions of its tools: Callbacks (old), Synchronous (blocking), and Promises (modern).
Real World Example
Writing a script that opens a massive `.csv` file full of user data, converts it to JSON, and saves the new JSON file back to the hard drive.
Common Use Cases
- •Reading config files
- •Saving user uploads
- •Generating dynamic logs
Interactive Example
Loading...
Console output will appear here...
Interview Questions
basic
- How do you import the promise-based version of the fs module?
intermediate
- Why should you avoid using `fs.readFileSync()` in a web server route?
advanced
- How do you read a file that is too large to fit in RAM?