Read, create, update, delete, and rename files using the Node.js fs module (fs.readFile, fs.writeFile).
Node.js Backend & Express
Node.js Tutorial
Advertisement
Google AdSense Slot (LEADERBOARD)
Automated High-CTR Ad Rail • Set Publisher ID in config/adsense.php
I/O
7 min read
•
Chapter 4 of 5
Node.js File System (fs)
Read, create, update, delete, and rename files using the Node.js fs module (fs.readFile, fs.writeFile).
Example
<!DOCTYPE html><html><body style="font-family:monospace;padding:20px;"><pre>const fs = require('fs');\nfs.readFile('demofile1.html', function(err, data) {\n res.writeHead(200, {'Content-Type': 'text/html'});\n res.write(data);\n return res.end();\n});</pre></body></html>
Try it Yourself >>
Opens live sandboxed code editor
Advertisement
Google AdSense Slot (IN-ARTICLE)
Automated High-CTR Ad Rail • Set Publisher ID in config/adsense.php
Community Q&A & Discussion
Verified
No questions yet. Be the first to start the discussion!