Node.js comes with a standard module for interacting with the file system. The file system, or fs module, is used to list files and directories, create files and directories, stream files, modify file permissions, and more. In this video, learn how to list files from a directory, as well as how to build a file CLI.
- [Instructor] Node.js also ships with a module … that allows us to interact with the file system. … The fs module can be used to list files in directories, … create new files in directories, stream files, … watch files, modify file permissions, … just about anything you would need … to work with files and directories. … So first let's get started … by listing the contents of a directory. … You will notice within the start folder … of the exercise files under chapter five, … chapter five lesson one, there's a asset's directory. … And we have a couple of files within this directory. … So let's say we wanted to read the contents … of this directory. … We would start by creating a new Node module called list.js. … And notice that I've put the list Node module … on the same level as the asset's directory. … Within the list.js file I'm going to go ahead … and load the fs module by using the require function … and we're going to require the fs module. … Now I can read the contents of a directory …
- What is Node.js?
- Installing Node.js
- The global object
- Importing the core modules
- Creating custom events with the EventEmitter
- Reading, writing, and removing files
- Working with file streams
- Creating child processes with the exec and spawn functions
Skill Level Intermediate
Node.js: Real-Time Web with Socket.IOwith Emmanuel Henri1h 24m Intermediate
1. What Is Node.js?
2. Set Up Your Environnment
3. Node Globals
4. Node Modules
5. File System Basics
6. Files and Streams
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.