You can also use the fs module to append files. In this video, learn how to add on to existing files that are part of your directory.
- [Lecturer] You can also use the FS module to append files, … let's go into our start folder … and make a brand new file called append.js. … Now, one of the things that I want to point out is, … if you look in your assets folder … you'll notice a colors.json document. … If I look at this document, it's just a JSON object … that has some values, including a description … and a color list. … So we don't need to use the File System … to read JSON documents, I can go directly into my append.js … and import this data simply by requiring it. … I'll call it colorData, … and then I'm going to go ahead and require ./assets … /colors.json … and then, within this colorData file … I can actually use this information, … so I can say colorData … .colorList … and the colorData.colorList should give us this array, … this list of colors, … so what I'm going to do is loop through the array using forEach … and then we send a callback function to the forEach function … and the c is going to refer to each of these colors …
Author
Updated
4/2/2020Released
5/10/2019- 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
Duration
Views
Related Courses
-
Databases for Node.js Developers
with Daniel Khan3h 1m Intermediate -
Node.js: Real-Time Web with Socket.IO
with Emmanuel Henri1h 24m Intermediate
-
Introduction
-
1. What Is Node.js?
-
Node.js history1m 1s
-
How Node.js works3m 32s
-
-
2. Set Up Your Environnment
-
Using VS Code1m 58s
-
Install Node.js1m 18s
-
-
3. Node Globals
-
The global object2m 28s
-
The require function2m 52s
-
Standard output3m 52s
-
Standard input6m 9s
-
Incorporate setInterval3m 11s
-
-
4. Node Modules
-
Core modules5m 18s
-
Use readline functions7m 22s
-
Export custom modules4m 14s
-
Create a module4m 54s
-
-
5. File System Basics
-
List directory files4m 15s
-
Read files3m 56s
-
Write and append files2m 27s
-
Directory creation2m 7s
-
Append files3m 59s
-
Rename and remove files2m 50s
-
-
6. Files and Streams
-
Readable file streams4m 43s
-
Writable file streams4m 41s
-
-
Conclusion
-
Next steps45s
-
- 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.
CancelTake 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.
Share this video
Embed this video
Video: Append files