Now that we've created this organization we're going to create our shared common library and then immediately
tried to publish it to this organization that we just created to get started.
I can go back over to my terminal I'm inside of my ticketing directory inside of you're going to make
a new folder called common.
So this is where we're gonna place all of our common logic.
We want to have access to between our different services.
I'll change into common and then I'm going to generate a package not just on file inside there with
NPM in it.
Dash why I'm then going to go over it's my code editor and make a couple changes to that package on
file.
Now there's a lot of settings inside of here that you might have ignored over time usually as developers.
We really just care about the script section and dependencies and Dev dependencies and not much else.
Now that we are going to actually be publishing a package the name and version fields are squint to
start to become very very important.
There are a couple of other fields we're going to focus on over time.
But right now let's just focus on name and version for name.
We're gonna specify obviously the name of our package but because we are publishing our package inside
of the organization that we just created.
We're going to use a very special format for our name for the name of our package.
We're going to take a look at our organization name.
For me it's as G tickets and then right here inside the Name field I'm gonna change that to at SGI tickets
slash and then the name of this very particular package I'm going to call mine simply common by putting
our name in as this format.
This means that we want to publish a package called Common to the SGI tickets organization
all right.
So now that we've got that name in there I'm going to save this file.
Now I want to immediately attempt to publish this package to my organization or the NPM registry to
publish this thing.
We're gonna go back over to our terminal.
We're gonna make sure we're still inside of our common directory and inside here we're gonna first begin
by creating a new get repository in order to publish a package.
We must have everything inside this directory committed to get NPM is going to check our get repo created
inside this folder and make sure everything has been committed before we intend to publish it.
So I'm going to create a new get repository by run and get in it all then add everything inside of here
and then I will commit all of it as initial commit and then after that we can then attempt to publish
this package to our organization to do so we'll write out NPM publish and then dash dash access public
if we do not add on this access public flag right here.
Then NPM is going to assume that we want to publish this as a private package inside of our organization.
We'll then throw an error because we have to pay money to publish a private package all right.
I'm gonna run that command and we should after a little pause here eventually see the thing published.
Now very quickly if you immediately see an error message if you see something it says You must log in
or something says you do not have access and make sure that you run the command NPM log in you'll be
prompted to enter in your username and password right here you'll want to enter these same username
and password they use back over here on NPM j ust dot com hopefully you will be able to publish this
thing once we've published this module we can now install it into any of our other services we can also
take a look at our published package on NPM j ust dot com itself it's a matter of fact if I go back
over to my organization page I can refresh it then go to the packages tab and I'll see my published
package right there so this can now be installed into any other module or any other project I'm working
on very easily the same way you're already used to we just have to run npm install and then put in our
package name okay.
Now that we've got this thing or at least an initial version of it published.
Let's take a pause right here and start to add in some actual implementation for our common module in
just a moment.