When you want to write or append data in files, you can use the file system module. In this video, learn how to use the writeFile and appendFile methods. Also, learn how to work with ECMAScript 6 or ES6 template strings, as well as how to create and append text files.
- [Male Instructor] So the file system module … can also be used to create new files … and write data to files. … In this lesson, we're going to look at the write file method … that's provided with the file system module. … I'm going to come over here to my start folder … and create a new file called "writefile.js". … And within the writefile.js, … the first thing we're going to do is require the file system. … So we're going to require our fs module. … And then the next thing we're going to need is some text. … We will write some text to a file, … so I'll just go ahead and create some markdown text, … using a template string so that we honor the white space. … And we'll say, "this is a new file." … So we can write text to a file with fs writefile. … So, so far we have learned fs.readdir, fs.readfile, … and now we're going to learn fs.writefile. … So I'll just jot these down as notes within our markdown. … So let's say I wanted to write this to a new file. … I'll just use fs.writefile …
- 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.