1 00:00:01,270 --> 00:00:02,680 So now that you know the 2 00:00:02,680 --> 00:00:05,850 absolute fundamentals of Node.JS., 3 00:00:05,850 --> 00:00:07,820 let's take the rest of the section 4 00:00:07,820 --> 00:00:10,350 to talk a little bit about npm, 5 00:00:10,350 --> 00:00:12,713 so the node package manager. 6 00:00:14,390 --> 00:00:17,490 So the node package manager is a command line 7 00:00:17,490 --> 00:00:20,200 interface app that automatically comes 8 00:00:20,200 --> 00:00:22,520 included with Node JS 9 00:00:22,520 --> 00:00:24,770 in which we use to install and manage 10 00:00:24,770 --> 00:00:26,870 Open Source packages. 11 00:00:26,870 --> 00:00:29,350 Now these packages that I just mentioned, 12 00:00:29,350 --> 00:00:32,020 they usually come from the package repository 13 00:00:32,020 --> 00:00:33,467 that is also npm. 14 00:00:34,390 --> 00:00:37,250 So at npm.js, you can take a look 15 00:00:37,250 --> 00:00:39,880 at all the modules or packages 16 00:00:39,880 --> 00:00:43,530 that are included in the npm repository. 17 00:00:43,530 --> 00:00:47,100 So npm is actually both the command line interface app 18 00:00:47,100 --> 00:00:49,650 that we use to manage the packages 19 00:00:49,650 --> 00:00:51,873 and also the repository itself. 20 00:00:53,323 --> 00:00:55,050 And actually, it's the largest software 21 00:00:55,050 --> 00:00:56,700 registry in the world, 22 00:00:56,700 --> 00:00:59,530 no matter what language we're talking about. 23 00:00:59,530 --> 00:01:01,130 And by the time of this recording, 24 00:01:01,130 --> 00:01:04,210 it has about 800,000 packages. 25 00:01:04,210 --> 00:01:06,880 So sometime, in the near future 26 00:01:06,880 --> 00:01:09,940 it will probably have over a million packages 27 00:01:09,940 --> 00:01:11,800 here on npm. 28 00:01:11,800 --> 00:01:14,450 So, let's for example, search for express, 29 00:01:14,450 --> 00:01:17,250 which is the node framework that we're going to use 30 00:01:17,250 --> 00:01:19,870 throughout most of the rest of the course. 31 00:01:19,870 --> 00:01:21,940 And so, for example, 32 00:01:21,940 --> 00:01:23,620 you can then click on it, 33 00:01:23,620 --> 00:01:25,430 and here you have all the information 34 00:01:25,430 --> 00:01:28,160 about each of the modules. 35 00:01:28,160 --> 00:01:29,890 So you can see that, for example, 36 00:01:29,890 --> 00:01:33,550 this one is download almost eight million times 37 00:01:33,550 --> 00:01:35,410 in the last week. 38 00:01:35,410 --> 00:01:38,803 So you see that it's a hugely popular package. 39 00:01:40,180 --> 00:01:43,350 Then, here, usually you have some documentation. 40 00:01:43,350 --> 00:01:45,870 But for now, that doesn't really matter. 41 00:01:45,870 --> 00:01:50,514 So for now, we're just interested in what npm actually is. 42 00:01:50,514 --> 00:01:53,260 Probably, you have used npm, yourself, 43 00:01:53,260 --> 00:01:56,870 before when working on front-end development. 44 00:01:56,870 --> 00:02:00,580 Because these days, npm is actually not just used 45 00:02:00,580 --> 00:02:01,860 for node development, 46 00:02:01,860 --> 00:02:05,130 but really across the entire Java's stack. 47 00:02:05,130 --> 00:02:07,920 So, for example, if you'll search for react, 48 00:02:07,920 --> 00:02:09,950 it's also gonna be here. 49 00:02:09,950 --> 00:02:11,890 So really, all these popular libraries 50 00:02:11,890 --> 00:02:12,860 and frameworks, 51 00:02:12,860 --> 00:02:16,813 they are all really on the npm registry. 52 00:02:18,490 --> 00:02:23,490 Basically, npmjs.com is where all these packages are hosted. 53 00:02:24,150 --> 00:02:27,150 Now, about the command line interface, itself, 54 00:02:27,150 --> 00:02:31,220 it actually comes already pre-installed with NodeJS. 55 00:02:31,220 --> 00:02:33,190 So, let's now actually start using it, 56 00:02:33,190 --> 00:02:35,400 and go back to our project. 57 00:02:35,400 --> 00:02:38,550 So here we have still our terminal open, 58 00:02:38,550 --> 00:02:41,000 but I'm gonna quit now this process here, 59 00:02:41,000 --> 00:02:45,160 so I hit control c and then clear the terminal. 60 00:02:45,160 --> 00:02:49,850 Npm is a software that we basically use to manage 61 00:02:49,850 --> 00:02:52,710 the third party Open Source packages that 62 00:02:52,710 --> 00:02:56,390 we choose to include and use in our project. 63 00:02:56,390 --> 00:02:58,190 And the first thing that they usually do 64 00:02:58,190 --> 00:03:00,400 whenever we start a new project, 65 00:03:00,400 --> 00:03:02,550 is to start with npm init. 66 00:03:04,030 --> 00:03:08,570 So we use npm as the command and then init. 67 00:03:08,570 --> 00:03:12,020 And this will basically create a package.jason file. 68 00:03:12,020 --> 00:03:16,110 Which is kind of a configuration file of our project 69 00:03:16,110 --> 00:03:19,780 where all kinds of data about the project is stored. 70 00:03:19,780 --> 00:03:23,190 We're gonna see more about that once that is finished. 71 00:03:23,190 --> 00:03:26,670 So npm init is now asking us a bunch of questions 72 00:03:26,670 --> 00:03:28,510 as you see down here. 73 00:03:28,510 --> 00:03:30,160 And, maybe, if you're not seeing it, 74 00:03:30,160 --> 00:03:32,630 I will increase this a bit. 75 00:03:32,630 --> 00:03:34,760 So, first thing that we need to specify 76 00:03:34,760 --> 00:03:36,400 is the package name. 77 00:03:36,400 --> 00:03:38,253 And this one is called node farm. 78 00:03:40,440 --> 00:03:43,790 So we need to use a url friendly name here, 79 00:03:43,790 --> 00:03:45,490 so that's why I have the hyphen. 80 00:03:45,490 --> 00:03:47,580 And what you see here is the suggested name, 81 00:03:47,580 --> 00:03:50,020 but I don't want the one in there, 82 00:03:50,020 --> 00:03:52,630 so I just retype node farm here. 83 00:03:52,630 --> 00:03:54,110 Then we have the version, 84 00:03:54,110 --> 00:03:56,247 so we can just hit return here on this one. 85 00:03:56,247 --> 00:04:01,247 And in the description, learning node js. 86 00:04:01,470 --> 00:04:03,940 The entry point is the next.js, 87 00:04:03,940 --> 00:04:05,840 but again, this doesn't really matter. 88 00:04:05,840 --> 00:04:07,420 We don't have any test command, 89 00:04:07,420 --> 00:04:09,053 so just hit return again. 90 00:04:10,040 --> 00:04:11,810 Now we'll get keywords, 91 00:04:11,810 --> 00:04:13,460 doesn't really matter again. 92 00:04:13,460 --> 00:04:14,913 The author is me. 93 00:04:15,840 --> 00:04:18,400 You can put your own name, of course, 94 00:04:18,400 --> 00:04:21,470 and license and so, 95 00:04:21,470 --> 00:04:25,240 one that's okay, to confirm that this is the file 96 00:04:25,240 --> 00:04:26,073 that we want. 97 00:04:27,260 --> 00:04:30,473 Actually, it created it right away here on this left side. 98 00:04:32,660 --> 00:04:34,193 Bring it down again here. 99 00:04:37,350 --> 00:04:40,370 So, indeed, this is our package Jason file, 100 00:04:40,370 --> 00:04:42,180 with this very basic information 101 00:04:42,180 --> 00:04:44,200 about the project for now. 102 00:04:44,200 --> 00:04:46,780 But there is a lot of stuff that can be added 103 00:04:46,780 --> 00:04:51,290 to this file and we will do so later in another project. 104 00:04:51,290 --> 00:04:54,750 Also, right in the next video which is where we're gonna 105 00:04:54,750 --> 00:04:56,260 installing packages. 106 00:04:56,260 --> 00:04:59,610 And these packages are then also registered here 107 00:04:59,610 --> 00:05:03,300 in this file so that we can keep tract of all the packages 108 00:05:03,300 --> 00:05:04,623 that we're actually using. 109 00:05:05,660 --> 00:05:09,380 So, in our next video we're then going to finally install 110 00:05:09,380 --> 00:05:11,263 some real packages here.