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 …
- 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.