0 1 00:00:00,650 --> 00:00:00,980 All right. 1 2 00:00:00,980 --> 00:00:05,990 So now that you've got Node and Hyper installed, it's time to check it out and see what we can do 2 3 00:00:05,990 --> 00:00:07,480 using Node.js. 3 4 00:00:07,580 --> 00:00:12,890 So the first thing I'm going to do is I'm going to create a new folder on my desktop. 4 5 00:00:12,890 --> 00:00:15,710 But this time I'm going to do it slightly differently. 5 6 00:00:15,710 --> 00:00:21,500 I'm going to be using our brand new Hyper Terminal, and we can issue it commands in order to get it to 6 7 00:00:21,500 --> 00:00:22,880 do what we want. 7 8 00:00:22,880 --> 00:00:26,380 So the first thing I'm going to type is pwd, 8 9 00:00:26,960 --> 00:00:30,370 and this stands for print working directory, 9 10 00:00:30,500 --> 00:00:37,170 so print where we are currently. Now working with the command line involves a little bit of imagination. 10 11 00:00:37,280 --> 00:00:43,280 You have to be able to imagine where you are in this giant filing cabinet. 11 12 00:00:43,280 --> 00:00:48,780 So, for example, you might have a cabinet and it has three drawers. Inside the first drawer 12 13 00:00:48,800 --> 00:00:51,820 there might be three folders. Inside the first folder 13 14 00:00:51,830 --> 00:00:53,720 there might be another three folders. 14 15 00:00:53,870 --> 00:00:57,340 So this is how directories work on your computer. 15 16 00:00:57,560 --> 00:01:03,650 And we're going to go into this in a lot more detail in the next module, where we explore everything 16 17 00:01:03,650 --> 00:01:05,510 that we can do using the command line. 17 18 00:01:05,690 --> 00:01:11,840 But here's a little bit of a taster, or a sneak peek, of the fun things that are yet to come. 18 19 00:01:11,840 --> 00:01:15,520 So by using the pwd command and hitting enter, 19 20 00:01:15,800 --> 00:01:22,430 we get printed out a number of lines that shows us where we are in this giant filing cabinet. 20 21 00:01:22,580 --> 00:01:25,280 So the starting point is called the root, 21 22 00:01:25,460 --> 00:01:27,730 and then we're inside a folder called Users, 22 23 00:01:27,830 --> 00:01:31,190 and inside that folder there's another folder called angelayu. 23 24 00:01:31,370 --> 00:01:37,220 So if you're used to a graphical interface, this is basically where we are. We’re inside this current folder, 24 25 00:01:37,760 --> 00:01:41,740 and you can see that the folder above it is called Users, 25 26 00:01:41,750 --> 00:01:49,040 and then if I double click on this folder called angelayu, then I get into my home folder, and from here 26 27 00:01:49,040 --> 00:01:52,100 you can see that we have our Desktop folder. 27 28 00:01:52,310 --> 00:01:59,240 So in order to move over there, then all I have to do is write cd, which is the command, and it stands for 28 29 00:01:59,240 --> 00:02:05,400 change directory, or change folders, and we're going to change over to Desktop. 29 30 00:02:05,990 --> 00:02:12,000 Now you can either type it out entirely, so Desktop. I don’t know why I just turned 30 31 00:02:12,080 --> 00:02:19,370 Japanese just now. Or you can simply start writing, say De, and then you can hit the tab in order for 31 32 00:02:19,370 --> 00:02:20,880 it to auto complete. 32 33 00:02:20,930 --> 00:02:26,840 Now, for example, if you only wrote the word D and you have multiple items like Documents, Downloads, Desktop, 33 34 00:02:27,200 --> 00:02:30,540 then it won't know what to suggest, so it won't come up with anything. 34 35 00:02:30,590 --> 00:02:36,890 But if you give it enough characters for it to be able to identify a unique name, then hitting that tab key 35 36 00:02:37,070 --> 00:02:39,400 will auto fill the rest of it. 36 37 00:02:39,410 --> 00:02:46,590 So now, if I hit enter, I am now inside the Desktop folder. As you can see, that's what's showing up. At 37 38 00:02:46,600 --> 00:02:53,750 the colon is our current location. And we can confirm that with the full directory path by using pwd. You can see 38 39 00:02:53,750 --> 00:02:57,890 that we're inside Desktop, which is inside angelayu, which is inside Users. 39 40 00:02:57,950 --> 00:03:04,330 Now once we're on to the Desktop, so I'm going to do it side by side with Finder over here as well, 40 41 00:03:04,340 --> 00:03:12,650 now once we're inside Desktop, we can use a command called ls which simply just lists everything that 41 42 00:03:12,650 --> 00:03:15,440 currently exists inside our location. 42 43 00:03:15,650 --> 00:03:18,080 So now we can see what exists here. 43 44 00:03:18,320 --> 00:03:23,390 And we've got something called Web Development, something called App Development, two folders. 44 45 00:03:23,460 --> 00:03:30,770 Now, if I wanted to make a new folder at this current location, Desktop, all I have to do is write the 45 46 00:03:30,770 --> 00:03:39,940 command make dir, or mkdir, and this makes a new directory, or rather new folder. 46 47 00:03:39,950 --> 00:03:44,110 It's the equivalent of hitting right click and clicking on New Folder. 47 48 00:03:44,150 --> 00:03:50,770 And then we have to specify the name of the folder, and I'm going to call mine intro-to-node. 48 49 00:03:50,990 --> 00:03:54,800 So you can have it capitalized if you want, but I'm just going to keep it lower caps 49 50 00:03:54,860 --> 00:03:57,380 and also with hyphens in between. 50 51 00:03:57,500 --> 00:04:01,910 And now, if I hit enter, I have a new folder called intro-to-node. 51 52 00:04:02,090 --> 00:04:05,760 Cool, right? Now, if you haven’t used command line before, 52 53 00:04:06,020 --> 00:04:14,300 it really is built for power users, because we can do so much stuff that Apple or Windows has kept 53 54 00:04:14,390 --> 00:04:15,280 away from us. 54 55 00:04:15,320 --> 00:04:19,850 And I think using the graphical interface is kind of like riding a bicycle with training wheels. 55 56 00:04:19,850 --> 00:04:25,760 This is more like a full blown Hayabusa motorcycle. With great power comes great responsibility, and 56 57 00:04:25,760 --> 00:04:29,840 we're going to talk a lot more about that in the command line module that's yet to come. 57 58 00:04:30,050 --> 00:04:37,190 But now that we've created our folder called intro-to-node, I'm going to then cd, or change directory, into 58 59 00:04:37,190 --> 00:04:38,560 that folder. 59 60 00:04:39,380 --> 00:04:42,260 And now I am inside this location, 60 61 00:04:42,260 --> 00:04:44,320 so the equivalent of being here. 61 62 00:04:44,630 --> 00:04:47,430 And if I hit ls here you can see that there's nothing. 62 63 00:04:47,480 --> 00:04:49,300 It's completely empty so far. 63 64 00:04:49,460 --> 00:04:55,570 So we're going to create a new file here, and the command for creating new files is touch. 64 65 00:04:55,580 --> 00:05:00,430 So we're going to say touch and then we're going to specify the name of the file. 65 66 00:05:00,860 --> 00:05:04,240 So we're going to say touch index.js. 66 67 00:05:04,400 --> 00:05:09,950 And now, if I hit enter, you can see, wow, brand new file that's just been created out of mid air. 67 68 00:05:10,220 --> 00:05:14,990 So if we double click on this, it should open up in Atom. If it doesn't, 68 69 00:05:15,050 --> 00:05:19,270 then make sure you right click and tell it where to open to, which is Atom. 69 70 00:05:19,520 --> 00:05:26,690 And inside this file, we’re going to simply create a console.log that just says, “Hello, world!” 70 71 00:05:26,690 --> 00:05:34,310 Up till now, we've only been able to run this code if we incorporated it into an HTML file and opened 71 72 00:05:34,310 --> 00:05:36,330 it inside our browser. 72 73 00:05:36,620 --> 00:05:39,390 But now we're going to do something slightly crazy. 73 74 00:05:39,410 --> 00:05:46,220 We're going to run this code using our computer, and we can do that by simply being inside the folder 74 75 00:05:46,610 --> 00:05:48,110 where that file exists, 75 76 00:05:48,110 --> 00:05:53,270 so when I hit ls I should be able to see the file that I want to run, and then I'm going to use the 76 77 00:05:53,270 --> 00:05:57,050 command node index.js. 77 78 00:05:57,110 --> 00:06:01,970 So this says use Node to run this file. 78 79 00:06:01,970 --> 00:06:09,050 And now, if I hit enter, you can see that the result of that file, which was simply to console.log “Hello, 79 80 00:06:09,050 --> 00:06:15,560 world!”, gets executed, and it gets logged inside my Hyper Terminal. 80 81 00:06:15,560 --> 00:06:18,770 So that was our first Node.js file that we executed. 81 82 00:06:18,770 --> 00:06:24,080 Now, in the next lesson, I want to talk to you about the REPL, the Read Evaluation Print Loop. 82 83 00:06:24,140 --> 00:06:26,960 So for all of that and more, I’ll see you on the next lesson.