Chapter 4
Accessing the File System
IN THIS CHAPTER
Reading from files
Writing to files
Using the synchronous API
Using the asynchronous API
Understanding paths
Retrieving file and directory information
“An ounce of performance is worth pounds of promises.”
—MAE WEST
Node.js's built-in fs module is what enables Node.js programs to manipulate files. As you may have guessed, the name fs is short for file system. If a program running in Node.js has the proper permission, it can do anything with files that you can do with any other program on your computer, including reading from files, creating files, writing to files, deleting files, moving files, renaming files, setting file permissions, and changing a file’s metadata.
Importing the fs module
The fs module comes in two flavors: the older, callback-based flavor and the up-to-date version that supports Promises. In addition to the ...
Get JavaScript All-in-One For Dummies now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.