Node.js · 14-day planAll days
Day 4 of 14 30 minfspathJSON files
Read and write files with the fs module. Compare the synchronous, callback and promise APIs, build paths safely with path, work with folders, store data as JSON, and handle errors like a missing file.
By the end of today you can
- Read and write text files with fs/promises
- Choose between sync, callback and promise versions of fs functions
- Build and take apart file paths with the path module
- Create, list and remove folders
- Save and load JSON data and handle missing files
What's inside
- 5 sections
- 2 diagrams and mind maps
- 5 code examples you can run
- 5-question quiz
- 1Reading and writing files
- 2Sync, callbacks or promises?
- 3Building paths
- 4Folders
- 5Storing data as JSON
Sign in free to read this lesson
Get the full lesson with diagrams, runnable code and the quiz. Your progress is saved across devices.
Sign in free