From the course: Node.js Essential Training
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Writing and appending files - Node.js Tutorial
From the course: Node.js Essential Training
Writing and appending files
- [Instructor] The fs module can also be used to write or append data to a file. In this lesson, we'll take a closer look. Let's create a new file here called writeFile and we're going to import the file system module, as you might expect. And then we're going to create some Markdown. So we're going to create a little template here. We'll say let md equal, we'll use a couple back ticks. And then within this, we'll say this is a New File. We'll underline this with equal signs for our header, and we'll say ES6 Template Strings are cool. They honor whitespace. And then we'll add some bullets here. So we'll say Template Strings, Node File System, and Readline CLIs. Cool. So now that I've created that, I can create a new file, and write the Markdown contents to this file. So we'll do this here on line 14 with fs.writeFile. Now, what writeFile is going to take in? It needs to take in the name of the new file. So…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Listing directory files2m 25s
-
(Locked)
Reading files2m 19s
-
(Locked)
Writing and appending files3m 22s
-
(Locked)
Creating directories2m 26s
-
(Locked)
Renaming and removing files3m 29s
-
(Locked)
Renaming and removing directories3m 57s
-
(Locked)
Readable file streams5m 47s
-
(Locked)
Writable file streams4m 47s
-
(Locked)
-