Node.js Tutorials
Lección 4 de 14 · Node.js Part 4 – NPM · Tecnología de la información
Node.js Part 4 – NPM
hey guys I wanted to just quickly go over NPM which is basically the package manager for node it stands for node package modules or
sometimes node package manager and the NPM JFS org that's the official website and you can find basically all the modules that are available you can see we have the recently updated modules the
most dependent upon which are basically the most popular I see Express which is the MVC framework that we'll be using the underscore templating system so there's just a bunch that you can go
through so I would definitely suggest coming to the website and looking around if you click on API this is basically the documentation for all the functions and functionality that's available to us
we won't be using too many of these there's some simple things we'll be using like LS to show what packages we have installed install which will basically install all the dependencies
that we have listed in our package dot JSON file which wiki we can create with NPM and knit alright and it's basically a file that holds all of the metadata for our app it holds all the
dependencies we need you can add your git repository for the app things like that so that's what I want to do in this video so if we go to I have a folder in my C Drive called node apps which
doesn't have anything at the moment so I'm just going to create a folder called test app all right in I'm just going to create a file called a pas
now we can use NPM to create a package.json file so let's open up our bash let's open it up to the test app folder because if you right click and click get bash and of course you can use
your standard Windows command line or terminal if you're in Linux or Mac and what we're going to do is we're going to say NPM in it and by the way NPM comes bundled with
nodes so if you installed node then you have NPM so it's going to take us through a series of questions to compile this file for us this package JSON file first thing is the name of the app and
whatever's in parenthesis basically is what it's going to be if you don't type anything right so test app is fine version will just say 0 0 1 description so this is a sample app entry point all
right so this is going to be the main javascript file in our case will be fjs so we'll leave that test come in get repository you don't need to worry about keywords author you can throw your name
in there license default this is C I'll just say GNU GPL and then it's going to ask if this is okay you click enter and if we go back to our test app directory we now have a
package dot JSON file all right so this is what it looks like it's basically all the information that we typed in now what's nice about this is we can include all our dependencies in this file which
will basically be all the modules that we want to use for our app so after this app this main app j/s let's create a new line and we want to say Dependencies all right now what we want
to do here is basically add some JSON data and we want to add the modules that we want to use so this is just an example this test app we're not going to work with this after this video so I'm
just going to just just add a few modules in here let's say we want to use Jade which is an HTML engine help to write HTML in your views now you could put the version number here but what I
usually do is is just include the latest version we can do that with an asterisk alright so we'll include Jade and let's say we want stylus which is a CSS compiler type app and same thing we'll
say we want the latest version and we want to put a comma right here alright so we'll save this and let's say this was a working application someone could download it from your repository or
whatever and you don't have to include any modules inside of the the actual folder all they have to do or all we have to do is go to let's see we want to go to the test app directory
and CD test up alright so if we check out the contents now as long as we have that package JSON file we can say npm install and that's it no no other flags or anything like that and it's going to
go through and install all the modules that this particular app needs so now if we go to our test app folder we get this node modules folder which includes all the files for Jade and stylus alright so
and then these modules also have dependencies which are in their node modules folder they also have a package.json and if you look at their dependencies there's a bunch here as
well which all get installed just from that npm install command alright so that's that's how that works probably somewhere later on in the series we can actually create our own
module and upload it to the NPM registry it's pretty easy to do but for now I just kind of wanted to explain and PM it and what it is you can also go to the command line and you could say NPM
search and this is gonna this might take a few minute or two but basically just grabs all the it grabs the all the modules in the registry and gives you a name and description for them
and you can see there's a just a ton and if you create your own module and submit it at that will show up here as well all right so I'm not going to go through any of these but that's what you
can do if you want to view all the available modules so that's NPM in a nutshell that's really all there is to explain for up to this point in the next video
we'll be installing Express and we'll do that through NPM as well
Simple explanation of Node Packaged Modules (NPM). We will also create a package.json file using “npm init”