Join Alexander Zanfir for an in-depth discussion in this video Reading from files, part of Learning Node.js.
- There are two areas where heavy I/O takes place,…network and disc.…So let's take a look at disc access to begin with…by working with some files.…We'll start with reading files…and then move on to writing our own files.…In order to do that, we're going to require access…to the file system library that's built within Node,…but first let's start by creating a new file.…I'll call this read demo.js.…And now let's require in the file system library.…And we'll call it fs for short.…
And as you can see, the library itself is called fs.…The next command we'll perform…will be to read from the file,…but we don't have a file to read yet,…so let's create a temporary JSON file…and put some data into it.…We'll call this data1.json.…And in here, we'll simply create an object…that has a property name,…and I'll set that to John.…Now that we have our data JSON file, let's close that out,…and we'll read it into our redemo.…
The first thing we'll do is access the fs,…or file system object, with a function called readFile,…and that's with a capital F,…
- Installing Node.js
- Writing modules and packages
- Reading and writing files
- Working with frameworks: Express, Sails, and Koa
- Generating promises
- Working with generator functions
Skill Level Beginner
Q: When I try to install Bluebird/Express/Gulp/Sails/KOA using the Node Package Manager, it seems to install correctly in the terminal. But why doesn't my project folder change?
A: You need to make sure that you've navigated to your project folder in the terminal. For example, in this course Alexander is working from the C:\Dev\ folder both in Brackets and in the terminal.