Node FS
Node FS is a builtin module in Node.js that helps you work with files and operate on them.
Node FS File Operations
With Node FS, you may do following actions on files :
- Reading files
- Creating or Overwriting files
- Updating files
- Deleting files
- Renaming files
Include Node.js FS Module
To include Node.js FS module in Node.js program, use the following require() statement.
</>
Copy
var fs = require('fs');
Examples
Following tutorials, provide you examples on the possible file operations that could be done using Node.js File System builtin module.
- Node.js Read File – Node.js FS program to read a file
- Node.js Create or Overwrite File – An example Node.js FS program to demonstrate on how to create a new file or overwrite an existing file
- Node.js Write to File – Example Node.js FS program to demonstrate on how to create a file and write data to it or overwrite an existing file.
- Node.js Append to File – Learn Node.js FS to append data to an existing file.
- Node.js Rename File – Node.js FS example program to understand how to rename a file
- Node.js Delete File – Node.js FS example program to show how to delete a file
- Node.js Copy Folder – Node.js FS Extra example program to copy an entire folder and its contents to another folder
Conclusion
In this Node.js Tutorial, we have learnt to work with files using Node.js FS Module