OK.
So we saw expressway introduced it.
Now let's get down to work to install it and let's make our first simple web.
And I don't want to get your hopes up too much.
This web app is going to be very very bare bones basically will be a web site you hit enter or you go
to the you are l and we just get a single message back saying what everyone can Gretz or hello or something
nice and simple.
But the difference between doing that and then responding with I don't know a big beautiful Web site
with images and big text animations isn't that much as far as the code we have to write on the backend
which is what we're focusing on now.
It's the same idea you respond with some some content what you respond with that's a different story.
OK.
So don't run this is a big red red letter say but to install express like we've installed faker or re-installed
the Myers QOL package you just run NPM install and then the name of the package.
However rather than doing this this will work fine.
It will install.
I'm going to show you another way of using NPM.
That's a little bit nicer or a better practice and it involves running this first command.
What does this do.
NPM and it creates what's known as a package that japes on file.
So if that doesn't make any sense to you don't worry.
Basically when you make a new project let's say we're working on a big node project within it like a
web app and our web app might have 20 packages involved.
So we're only working with the couple right now but it could have 20 involved rather than just installing
them individually and leaving no record of what's been installed and what version has been installed.
What we can do is create a package that just on file and it acts as like a log file of everything we
install so that if I send my code to someone else across the world our posts don't get how.
For example all the person has to do to run it is take that packet Jaison and then run a single command
NPM install which will then go find the packet adjacent in and install every necessary package.
So let me show you an example.
This is actually the Get Home Depot for Express.
Yes the framework we're about to install which is itself it's a node package and there's a package not
just on file in it.
If you look there's this giant dependency section.
These are all different packages that express needs.
So when we install express it goes and installs all of these things as well.
So we don't have to do it right.
If this package that Jason wasn't here we would have to manually install array flatten and Content-Disposition
and KOKI.
Thankfully we don't even have to worry about what these do let alone the fact that they exist.
So that's the point of the package that Jason.
It's a way of storing not only the packages that are necessary within the version because this version
of express might be totally broken if we used 0.6.
If that exists or escape each time L is zero point zero point three instead of one point zero point
three.
So that all we'll say about it for now.
But to actually create the package based on what I'm going to do is first make a brand new folder just
so that we're working in a different folder.
And I'm going to just call this one.
Join us and that's where we'll be building the application to everything else we've done up until now
has actually been building the app.
So what I'll do is now CD into join us with the terminal down here and it should be empty.
If I type LS we're now in this directory there's nothing there.
So we're going to run this NPM init command and this will just generate a new package.
Jason.
However it's interactive so it's going to ask for a name and what you can do is just hit enter if you
want it to just accept what it is the default value is.
But if I hit Enter now I'll get a message saying sorry name can no longer contain capital letters so
let's do join us underscore version will say it's 1.0 over at that's fine description and we can leave
it blank for now.
Entry point I like to change to app japes.
This is just the name of the file that we're writing or app in or the main file of her app.
We could have 20 files.
But what's the start point index is fine too.
But I'm going to do app then I'm just going to hit enter until we're done.
You could put author in there as well.
And the license then you can see the basic text it generates for us.
Jason just a data format and all that enter.
Now I have a package that Jason File appear and it's ready for us to install things.
So now what I'm going to do is run NPM install express but not on its own.
I'm going to add dash dash save and that will save a record of our install into our package.
Jason So right now it's not here but if I do NPM install express dash dash save like that takes a moment.
You'll see first of all we have our node modules now instead of join us so we installed it in this directory
which is set then in our package that Jaison.
We now have Express saying 4.1 5.2 is our version.
And while we're here why not also just reinstall NPM install two other packages we need for our app.
The first one is faker.
And then the second is my ask.
Well you can just separate them by spaces and add dash dash.
Save and it will just add both of them in here too.
Not a deal breaker.
We already have installed them on this machine but it's nice to have them in this directory too and
also have records of them in our pack stuff Jason.
So now if I wanted to upload this to get hubby or something and share this with someone I wouldn't have
to you know send them the node modules folder and send them the actual express directory and faker in
my ask you if I could ignore that because this is the largest part of our directory structure right
now.
This I don't know how many megabytes it is but it's a lot more than the single file or our sim or single
app J.S. file.
So it's better to just have our friends or other developers download what they need remotely.
So I just send them this recipe that says oh by the way you need these three things.
Here's my code plus the package Jason.
Then they go take package Jason and they install these things.
And the way that you do that by the way is running NPM install and you don't add anything afterwards.
It will try and install everything in the nearest package that Jason.
All right.
So we have expressed installed.
We don't have an app yet.
Not even an app Jasc file but we have a structure that we need to create the app.