1 00:00:00,870 --> 00:00:06,000 Now that we've created this organization we're going to create our shared common library and then immediately 2 00:00:06,000 --> 00:00:10,160 tried to publish it to this organization that we just created to get started. 3 00:00:10,200 --> 00:00:16,150 I can go back over to my terminal I'm inside of my ticketing directory inside of you're going to make 4 00:00:16,150 --> 00:00:17,890 a new folder called common. 5 00:00:17,890 --> 00:00:21,120 So this is where we're gonna place all of our common logic. 6 00:00:21,160 --> 00:00:24,100 We want to have access to between our different services. 7 00:00:24,100 --> 00:00:28,870 I'll change into common and then I'm going to generate a package not just on file inside there with 8 00:00:28,900 --> 00:00:29,740 NPM in it. 9 00:00:29,740 --> 00:00:37,070 Dash why I'm then going to go over it's my code editor and make a couple changes to that package on 10 00:00:37,070 --> 00:00:40,200 file. 11 00:00:40,210 --> 00:00:45,680 Now there's a lot of settings inside of here that you might have ignored over time usually as developers. 12 00:00:45,760 --> 00:00:50,700 We really just care about the script section and dependencies and Dev dependencies and not much else. 13 00:00:50,800 --> 00:00:55,830 Now that we are going to actually be publishing a package the name and version fields are squint to 14 00:00:55,840 --> 00:00:58,060 start to become very very important. 15 00:00:58,060 --> 00:01:00,540 There are a couple of other fields we're going to focus on over time. 16 00:01:00,640 --> 00:01:05,030 But right now let's just focus on name and version for name. 17 00:01:05,030 --> 00:01:10,370 We're gonna specify obviously the name of our package but because we are publishing our package inside 18 00:01:10,370 --> 00:01:12,460 of the organization that we just created. 19 00:01:12,560 --> 00:01:16,990 We're going to use a very special format for our name for the name of our package. 20 00:01:17,030 --> 00:01:19,450 We're going to take a look at our organization name. 21 00:01:19,460 --> 00:01:26,270 For me it's as G tickets and then right here inside the Name field I'm gonna change that to at SGI tickets 22 00:01:26,330 --> 00:01:34,880 slash and then the name of this very particular package I'm going to call mine simply common by putting 23 00:01:34,910 --> 00:01:36,230 our name in as this format. 24 00:01:36,230 --> 00:01:41,630 This means that we want to publish a package called Common to the SGI tickets organization 25 00:01:44,170 --> 00:01:44,420 all right. 26 00:01:44,540 --> 00:01:47,480 So now that we've got that name in there I'm going to save this file. 27 00:01:47,510 --> 00:01:54,120 Now I want to immediately attempt to publish this package to my organization or the NPM registry to 28 00:01:54,120 --> 00:01:55,120 publish this thing. 29 00:01:55,160 --> 00:01:58,750 We're gonna go back over to our terminal. 30 00:01:58,840 --> 00:02:03,040 We're gonna make sure we're still inside of our common directory and inside here we're gonna first begin 31 00:02:03,040 --> 00:02:07,030 by creating a new get repository in order to publish a package. 32 00:02:07,030 --> 00:02:12,850 We must have everything inside this directory committed to get NPM is going to check our get repo created 33 00:02:12,880 --> 00:02:17,680 inside this folder and make sure everything has been committed before we intend to publish it. 34 00:02:17,710 --> 00:02:23,950 So I'm going to create a new get repository by run and get in it all then add everything inside of here 35 00:02:26,000 --> 00:02:32,840 and then I will commit all of it as initial commit and then after that we can then attempt to publish 36 00:02:32,840 --> 00:02:41,420 this package to our organization to do so we'll write out NPM publish and then dash dash access public 37 00:02:42,020 --> 00:02:44,710 if we do not add on this access public flag right here. 38 00:02:44,780 --> 00:02:49,750 Then NPM is going to assume that we want to publish this as a private package inside of our organization. 39 00:02:49,780 --> 00:02:54,920 We'll then throw an error because we have to pay money to publish a private package all right. 40 00:02:54,950 --> 00:03:01,790 I'm gonna run that command and we should after a little pause here eventually see the thing published. 41 00:03:01,790 --> 00:03:06,560 Now very quickly if you immediately see an error message if you see something it says You must log in 42 00:03:06,620 --> 00:03:12,470 or something says you do not have access and make sure that you run the command NPM log in you'll be 43 00:03:12,470 --> 00:03:17,860 prompted to enter in your username and password right here you'll want to enter these same username 44 00:03:17,860 --> 00:03:23,680 and password they use back over here on NPM j ust dot com hopefully you will be able to publish this 45 00:03:23,680 --> 00:03:29,980 thing once we've published this module we can now install it into any of our other services we can also 46 00:03:29,980 --> 00:03:35,500 take a look at our published package on NPM j ust dot com itself it's a matter of fact if I go back 47 00:03:35,500 --> 00:03:42,960 over to my organization page I can refresh it then go to the packages tab and I'll see my published 48 00:03:42,960 --> 00:03:48,930 package right there so this can now be installed into any other module or any other project I'm working 49 00:03:48,930 --> 00:03:54,000 on very easily the same way you're already used to we just have to run npm install and then put in our 50 00:03:54,000 --> 00:03:56,400 package name okay. 51 00:03:56,420 --> 00:04:00,650 Now that we've got this thing or at least an initial version of it published. 52 00:04:00,650 --> 00:04:05,210 Let's take a pause right here and start to add in some actual implementation for our common module in 53 00:04:05,210 --> 00:04:05,720 just a moment.