CHAPTER 3

image

Using the File System

In many instances within an application, you will want to work with the file system. Node.js makes this straightforward by creating a wrapper around standard file I/O operations that are present on the operating system. In Node.js these capabilities are centered around one of the Node.js native modules, fs. This chapter will provide examples of how to utilize the file-system module in your Node.js application. In this chapter you will learn how to perform these actions:

  • Retrieve directory structures
  • Navigate directories
  • Manipulate directory structures
  • Watch directories for modifications
  • Read and write files

Get Node.js Recipes: A Problem-Solution Approach now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.