In this video.
Let's go ahead and install our first package from NPM.
The first step is we need to create a folder for it and I've already created a folder called and PM.
So let's look at the syntax for installing package.
Well, we are going to install locally and this is a syntax we make use of NPM and then install and
the name of the package.
The name of the package can be found inside NPM website.
So if you go to NPM here, we can search for any package that we need for our application.
So let's say that we want a package that can generate colours randomly upon each request.
So let's set four colour.
Now if see that we have 14,000 packages found for this package.
So which of this one are we requesting for?
And PM has given us a tag called Exact Match.
Meaning this is what we actually searched for.
For this package we have a little bit description which says color, convention and manipulation with
CSS training support.
So if you click on that, you can see more details about the package.
Up here, we have the package, name the version, and then it's a public repository.
And then last update and under versions, if we see that this package has 48 versions, it tells you
that this package is always being updated.
Let's click on Read Me and this one gives you the installation steps on the right side here we have
more details about the package, how to install.
Since we have bunch of packages under color, which ones we use.
Well, always before you choose a package, take note about this one is the weekly downloads.
It tells you that this package is popular.
So if you use it, there be no problem in the future.
All right.
And then the last update, which is really important, it tells you whether this package is being updated
or maintained.
And you see a number of collaborators, one person who made this package for us, and this is a version
or the current version of this package.
So let's see how we can install and we can install the package using this syntax.
NPM I color or NPM install after installation this added usage telling you how we can use the package.
So first is let's go ahead and install the package.
So as I told you, we are going to use NPM, install or NPM IE and the name of the package.
So back to my terminal, I have already said in to the folder where I want to practice my NPM skills.
So the first step is I will make use of NPM I and then the name of the package which is color well,
but before we install this, we can give this one additional flag, meaning how do we want to install
this package?
One, we can install a package as dev dependencies, meaning that we need a particular package only
in a development mode or environment.
And we can also install the package as dependencies, meaning in production.
We may need that package in production.
So we have two types of packages, dev dependencies and the actual dependencies.
So if we want to install a package as a development dependencies, we are going to give it a flag and
PM I dash a package.
Now before we get into that, let's install this package as dependency.
And after some time you see that we have the package being added, meaning we have added six packages,
meaning that this package has been installed.
Now let's check our folder and indeed we have couple of files here after we initiated this command.
So what is this node modules and what is it doing over here?
Note modules was created automatically as soon as we install any package.
This means that this folder contains any package that we are going to use in this particular application.
And we only install color package by why from this one.
It means that these folders make up the entire color package.
That is the note module's for you.
And after that we have two files.
The first one is package does log dot JSON file.
I got this one simply because I am using two package managers that is young and PM.
If you have an PM only installed without John, you are not going to see this file, so let's remove
it.
Otherwise it's going to conflict.
Which manager should I use?
Now this is the most important one which is packaged dot json file.
So what is it?
This file contains all the scripts and dependencies that you are going to use for this application.
So this file manages our packages and how we can run our application.
If you go to express, you can see that you're going to have a bunch of properties inside this as your
application grows.
So now it has given us an object in a JSON format with key value per and property.
It will say that we have a property here called dependencies.
Like I said, that dependency simply means that our application relies on these packages, even in production
and in dev environment.
So now we can install this package in a different way.
But before that, let's finish up what is going on over here.
It can see that inside the dependencies here we have key value per property, name and value.
The property name represents the name of the package as we installed here, which is color.
And after that, we have a value which represents the version for this package.
So if you check the version, indeed it is 4.2.3.
That's what we have here.
That is it.
That is it, guys.
The next step is, how can we use it?
But before that, let me show you how we can install this package as dev dependencies.
So coming back here so we can give it additional flag as dash and uppercase z, meaning that we are
installing this package as def dependencies.
We need it only in development environment.
When I hit enter now let's have a look.
We see that instead of dependencies it has changed to def dependencies.
Meaning we need this package only in development environment in production application is going to use
this package.
That is how we can install package the next video.
Let's see how we can use a package.