WEBVTT 0 00:00.650 --> 00:00.980 All right. 1 00:00.980 --> 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 00:05.990 --> 00:07.480 using Node.js. 3 00:07.580 --> 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 00:12.890 --> 00:15.710 But this time I'm going to do it slightly differently. 5 00:15.710 --> 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 00:21.500 --> 00:22.880 do what we want. 7 00:22.880 --> 00:26.380 So the first thing I'm going to type is pwd, 8 00:26.960 --> 00:30.370 and this stands for print working directory, 9 00:30.500 --> 00:37.170 so print where we are currently. Now working with the command line involves a little bit of imagination. 10 00:37.280 --> 00:43.280 You have to be able to imagine where you are in this giant filing cabinet. 11 00:43.280 --> 00:48.780 So, for example, you might have a cabinet and it has three drawers. Inside the first drawer 12 00:48.800 --> 00:51.820 there might be three folders. Inside the first folder 13 00:51.830 --> 00:53.720 there might be another three folders. 14 00:53.870 --> 00:57.340 So this is how directories work on your computer. 15 00:57.560 --> 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 01:03.650 --> 01:05.510 that we can do using the command line. 17 01:05.690 --> 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 01:11.840 --> 01:15.520 So by using the pwd command and hitting enter, 19 01:15.800 --> 01:22.430 we get printed out a number of lines that shows us where we are in this giant filing cabinet. 20 01:22.580 --> 01:25.280 So the starting point is called the root, 21 01:25.460 --> 01:27.730 and then we're inside a folder called Users, 22 01:27.830 --> 01:31.190 and inside that folder there's another folder called angelayu. 23 01:31.370 --> 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 01:37.760 --> 01:41.740 and you can see that the folder above it is called Users, 25 01:41.750 --> 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 01:49.040 --> 01:52.100 you can see that we have our Desktop folder. 27 01:52.310 --> 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 01:59.240 --> 02:05.400 change directory, or change folders, and we're going to change over to Desktop. 29 02:05.990 --> 02:12.000 Now you can either type it out entirely, so Desktop. I don’t know why I just turned 30 02:12.080 --> 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 02:19.370 --> 02:20.880 it to auto complete. 32 02:20.930 --> 02:26.840 Now, for example, if you only wrote the word D and you have multiple items like Documents, Downloads, Desktop, 33 02:27.200 --> 02:30.540 then it won't know what to suggest, so it won't come up with anything. 34 02:30.590 --> 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 02:37.070 --> 02:39.400 will auto fill the rest of it. 36 02:39.410 --> 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 02:46.600 --> 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 02:53.750 --> 02:57.890 that we're inside Desktop, which is inside angelayu, which is inside Users. 39 02:57.950 --> 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 03:04.340 --> 03:12.650 now once we're inside Desktop, we can use a command called ls which simply just lists everything that 41 03:12.650 --> 03:15.440 currently exists inside our location. 42 03:15.650 --> 03:18.080 So now we can see what exists here. 43 03:18.320 --> 03:23.390 And we've got something called Web Development, something called App Development, two folders. 44 03:23.460 --> 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 03:30.770 --> 03:39.940 command make dir, or mkdir, and this makes a new directory, or rather new folder. 46 03:39.950 --> 03:44.110 It's the equivalent of hitting right click and clicking on New Folder. 47 03:44.150 --> 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 03:50.990 --> 03:54.800 So you can have it capitalized if you want, but I'm just going to keep it lower caps 49 03:54.860 --> 03:57.380 and also with hyphens in between. 50 03:57.500 --> 04:01.910 And now, if I hit enter, I have a new folder called intro-to-node. 51 04:02.090 --> 04:05.760 Cool, right? Now, if you haven’t used command line before, 52 04:06.020 --> 04:14.300 it really is built for power users, because we can do so much stuff that Apple or Windows has kept 53 04:14.390 --> 04:15.280 away from us. 54 04:15.320 --> 04:19.850 And I think using the graphical interface is kind of like riding a bicycle with training wheels. 55 04:19.850 --> 04:25.760 This is more like a full blown Hayabusa motorcycle. With great power comes great responsibility, and 56 04:25.760 --> 04:29.840 we're going to talk a lot more about that in the command line module that's yet to come. 57 04:30.050 --> 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 04:37.190 --> 04:38.560 that folder. 59 04:39.380 --> 04:42.260 And now I am inside this location, 60 04:42.260 --> 04:44.320 so the equivalent of being here. 61 04:44.630 --> 04:47.430 And if I hit ls here you can see that there's nothing. 62 04:47.480 --> 04:49.300 It's completely empty so far. 63 04:49.460 --> 04:55.570 So we're going to create a new file here, and the command for creating new files is touch. 64 04:55.580 --> 05:00.430 So we're going to say touch and then we're going to specify the name of the file. 65 05:00.860 --> 05:04.240 So we're going to say touch index.js. 66 05:04.400 --> 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 05:10.220 --> 05:14.990 So if we double click on this, it should open up in Atom. If it doesn't, 68 05:15.050 --> 05:19.270 then make sure you right click and tell it where to open to, which is Atom. 69 05:19.520 --> 05:26.690 And inside this file, we’re going to simply create a console.log that just says, “Hello, world!” 70 05:26.690 --> 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 05:34.310 --> 05:36.330 it inside our browser. 72 05:36.620 --> 05:39.390 But now we're going to do something slightly crazy. 73 05:39.410 --> 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 05:46.610 --> 05:48.110 where that file exists, 75 05:48.110 --> 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 05:53.270 --> 05:57.050 command node index.js. 77 05:57.110 --> 06:01.970 So this says use Node to run this file. 78 06:01.970 --> 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 06:09.050 --> 06:15.560 world!”, gets executed, and it gets logged inside my Hyper Terminal. 80 06:15.560 --> 06:18.770 So that was our first Node.js file that we executed. 81 06:18.770 --> 06:24.080 Now, in the next lesson, I want to talk to you about the REPL, the Read Evaluation Print Loop. 82 06:24.140 --> 06:26.960 So for all of that and more, I’ll see you on the next lesson.