Node.js & Express From Scratch [FINAL] – Deploying Our App
![*](https://i0.wp.com/allprowebdesigns.com/wp-content/uploads/2023/12/1703050311_maxresdefault.jpg?resize=840%2C430&ssl=1)
Video Title: Node.js & Express From Scratch [FINAL] – Deploying Our App
Alright guys so in this video what I want to try to do is deploy the application that we’ve been building now I haven’t done anything to kind of prepare for this so I’m just giving you a heads up that we may run into some issues and you know have some hiccups
But I think it’s good to kind of show the whole process from scratch because I mean that’s how it is in the real world you know you’re going to run into issues you’re going to you’re going to have to learn things as you go and I think it’s
Better to do it this way than to have it all you know a cookie cutter template of how it would look in a perfect world because it’s definitely not a perfect world when you’re a developer or a programmer so we’re going to be using digitalocean I would definitely suggest
Digitalocean for pretty much any kind of application nodejs Express Python PHP pretty much anything it’s they’re a really great company and they’re really cheap when you if you compare them to other Virk VPSs they’re very cheap so I have an account already so I’m going to
Log in here see what they do tech guy info and password so once you oh I have two factor authentication enabled so I just got to check my my text message real quick alright so let’s see c 8 c 8 3 4 alright and this is just a test
Account I don’t have any production sites or anything on this you can see I don’t have any droplets so if you’ve never worked with digitalocean they have droplets and a droplet is basically just a VPS it’s a virtual server and you have full access to it you can log in through
The shell and you can run any commands you want you can install whatever you want just like we did on our local machine ok so what we’re going to do is create a new droplet and there’s a couple different Linux distributions you can choose we’re going to stick with a
Bun too and as far as the payment goes you can add funds to your account and then you can purchase packages with fun’s all right so let’s say we want the lowest one which is $5 a month this is more than enough for testing and prototyping if you are running a
Production application you may want to add some more resources and go a little higher so let’s go down here and we want to add an SSH key because you want to be able to secure your account and I would suggest SSH into it instead of using a username and password and you can
Actually disable login functionality so that only your machine can tunnel into your SSH so let’s say new SSH key now to generate it since we’re in Windows it’s a little more difficult what we’re going to do is download the tool called putty ok so there’s actually two programs we
Need one is putty that’s used to connect through SSH and then puttygen is used to generate a an SSH key so let’s go ahead and click that you can download the putty here and we want to grab let’s see I’m on windows 64-bit so I’m going to
Grab that and then I’m also going to grab where is it putty Jam Exe 64-bit ok so we’re going to get both of those and then I’m just going to move those let’s go ahead and cut and we’ll put them in the C Drive and I’m just going to create
A new folder called putty ok we’ll paste that in there these aren’t installers these are the actual programs so let’s open up puttygen first all right and what we want to do here is click generate and it says move the mouse around here to generate and then this is
Our key right here so we want to grab from the beginning all the way to the end make sure you get the whole thing and let’s go ahead and copy that and then we’ll paste it in here and you see we get a little green checkmark and then
We can name it I’m just going to call this public key one all right and then let’s go back to potty Jen and what we want to do here is save the key so let’s say save public key and I’ll just save it to documents so we’ll call this public let’s say
Public dot key and then we also want to save the private key all right now you can put a passphrase if you want but I’m just going to leave it blank and I’ll click yes and then let’s say private key one and then this is going to have a PPK
Extension so let’s save that and we should be all set with this program so let’s close that up let’s continue on with this and then we’ll open up putty and we’ll connect so for a hostname you can pick whatever you want I’m just going to leave the default and then
Let’s just click create and now it’s going to go ahead and set up our server or droplet and now it’s all set so you can see we have an IP address and if we click on that we can go to basically our dashboard for the droplet and we can
Have we have graphs which aren’t available just yet but they will access we can actually launch a console here if we wanted to but we’re not going to do that we’re going to use our machines console let’s see power you can power it down you can upgrade if you want if you
Want to pay more and get more resources back up snapshots if you want to destroy it you can just go ahead and click on destroy and that’ll wipe it clean so what we want to do now is connect so we’re going to open up putty exe and if
You’re on Mac or Linux you can just use the SSH command and there’s ways to use it on windows too but we’re just going to use putty so let’s grab the IP address here let’s copy that actually and paste that in now we need to use our
Our key that we generated so we’re going to go down to data and let’s see we’re going to use for Auto login username will say root and then go down to SSH and off and then what we want to do is upload the private key that we created so let’s click
Browse and we want private key one and then let’s go back up to session and we’re going to save this so right here let’s just say I’ll just say deal one for a digital ocean one and save and now when we come here we can easily load it
Up all right so let’s click on open and it’s going to give us this this box the first time we connect we’re just going to say yes and now we’re in you see we didn’t even have to put in a password because we use the SSH key so now we can
Use this just like we would on our local machine and we can install stuff and you know set everything up so it’s going to be a little different because I was using windows on my client machine so you know installing MongoDB and stuff is a little different let me just make this
Bigger see I can I make this bigger change settings parents see change the font and let’s choose 24 that should be good there we go oh it’s yeah that’s fine at least I don’t have to worry about you guys not seeing it so let’s see first thing we’re going to do here
Is install node.js so installing node.js on a bun too is pretty easy if we go down to C to sit yeah right here so we want to run this curl command because by default it’s not in the repository so let’s grab this and we’ll just paste
That in here and we’ll run that that’ll make it so that we can then run apt-get install node j s so we’ll copy that actually we should probably do a sudo apt-get update first alright and then we’re just going to paste this into install mode and now if we say node dash
V you can see node is now installed as well as NPM so next thing we’re going to do is install MongoDB so let’s say MongoDB install Ubuntu okay so let’s see first thing we’re going to do is import public key by using the package package management system so we want to grab
This right here I’ll just click copy and let’s paste that in and run it alright and then we need to create a list file for MongoDB so we’re going to do we’re on a bun 2:16 so let’s grab this right here and then we already go to layout
Let’s just run an update again so sudo apt-get update and then we’re just going to run this we can now install it with apt-get all right and then to start it we can run this command start the service okay so then and now should be running if he wanted to stop it you
Could just go down you can run this right right here okay sudo service dee stop and you can also restart so now that that’s installed let’s go ahead and clone the repository so let’s go to github and let’s see um I’m not going to sign in I
Don’t need to let’s just search for me all wait this is searching repositories let’s search users and look someone actually created an account with my name so let’s go here and it should be right here node KB all right so we just want to basically clone this project so up
Here it says clone let’s grab this okay now it should be installed get okay so let’s go ahead and run git clone and then we’re just going to paste that in alright so if we look at our directory structure now we’re in the home directory we have node KB all right are
We in the home directory yeah we should be so what we’ll do now is CD into node KB look not JB and then from here let’s run actually let’s install node mod as well might as well so npm install – ji node lon okay so now let’s try to run it you know
What we have to run we have to run npm install to actually create install all the dependencies so let’s do that so this will look at the package.json file and install everything in it so that includes Mongoose it includes pug what else did we use Express messages all that stuff
Alright so now that’s done let’s try and run node Mon and it started so let’s grab our IP address go over here paste that in we want to go to port 3000 and there it is there’s our application so if we want to test things out let’s register let’s say Brad at Gmail
Username submit okay we’re registered let’s try logging in and there we go to add an article submit article added so our application is now live on the Internet now we want to do a couple things so one we don’t want to have to have this
Running in order to go to our website so what we can do is we can start it as a service so there’s a few different ways that we can do that one is by using something called p.m. – so this is the process manager for nodejs and we’re
Going to use this and we should just be able to do p.m. to start and then whatever our entry file is and it’ll run it in the background alright so let’s go ahead and do a ctrl C and stop this and then we’re going to do NPM install p.m.
– – G we want to install it globally all right once we do that we should be able to start it up okay so let’s do p.m. to start app dot J s okay so now it should be running in the background so it should still work if we go over to here
And refresh and it’s still running good so another thing you’d probably want is to not run it on a port like this 3000 now the default port for HTTP is port 80 but by default if we were to change the port number to 80 it’s not going to work
But we can actually install a package called Lib cap – – bin and that will allow us to run it on port 80 let me just search for that Lib cap – – pinned and see I guess does not implement to the user space interfaces all right so it’s
Not really not really a good description of it but we’re going to install that first we’re going to stop our application and we can do that with p.m. to stop fjs and then let’s go ahead and say sudo sudo apt-get install and it’s lib to cap – bin all right so now that
We have that installed we have to run a command let me see if I can find that there’s a few ways to do this to get it to run without having to go to a certain port where the heck is the package all right you know I’m just going to copy it
And paste it in and you guys can copy it all right so it’s sudo set cap and then you have this cap net bind service equals plus EP and then read link – F and by the way these are back ticks not quotes can I make sure you put those in
And then which node so let’s run that and then let’s start the actually we need to edit the application because we’ve set port 3000 we just want to go in and we want to change it to port 80 so just for simplicity I’m going to use Nano which is a terminal based text
Editor and we’re going to edit app j/s all right so let’s just change go down to the bottom and right here where we put three thousand we’re going to change that to eighty and we’ll say server started on port 80 okay and then we’re going to do
Control X yes to save or Y and then enter so now let’s go ahead and start the application again so we’ll say p.m. to start app j/s and now let’s go to just the IP address not the port and there we go alright so last thing that you’d probably want to do is
You want to use a domain name not an IP address and if we go to digital ocean and we go to let’s see networking and we want to add a domain now I actually have a domain pointed to digital ocean already let me just show you how to do
That I use I’m using UNAM Central but you can do this from whoever host your domain name or the registrar I’ll see I’m going to just log in here think this is my account not sure no maybe it’s tech i won there we go all right so the registered
Domains I have I think it’s cold learner yeah right here cold learner net so you basically want to go to your domain registrar and you want to edit the DNS records or the name servers so in this case with UNAM I would choose this DNS server settings and then you want to add
Three name servers ns1 digitalocean comm ns2 and ns3 and save it might take a little while for the domain to propagate but once it does you can come over here and you can say add domain and say cold learner dotnet or well obviously your own domain name and we’re going to add a
Couple records here so we want a a record so right here in host name we’re going to just say hat and over here we’re going to choose our droplet I only have one but if you have multiple they’ll all show up so we’re going to do
That say create record and then we also need to add a cname and in here let’s say WW because we want both versions of the domain just Kotler Nannette and wwk are Nannette we want those to point to the host so at is just representative of our host of our
IP address so let’s go ahead and click create record and we should be all set so now let’s go to code learner dotnet and there’s our application okay we should be able to login there we go so we now have a live nodejs an Express application now there’s other provisions that you
Should set up if this was a production server you want you want to add better security you shouldn’t be even logging in as the root user so create a new user and you might have to add the SSH key for that user as well I actually have a
Video that goes a little more in-depth on this process I forget exactly what it’s called it’s like deploy node to digitalocean or something like that all right so hopefully you guys enjoyed this I might add some more functionality to this I’m not sure I know that a couple people asked for file uploading
So that’s something I might look into but I did want to just get a deployment video out for now before I start to move on to other stuff and like I said in the first video laravel is coming I know a lot of you guys are asking for that so
That will be out soon and that’s it thanks for watching also guys if you can if you have a Twitter account go ahead and follow me Twitter coms slash traversée media I’m trying to to get I mean I’ve kind of neglected the account but I’m trying to get more followers
Because I want to be able to post you know updates about what’s coming up and and all that so if you guys can just you know subscribe on Twitter and you know that would be that would be helpful so thanks for watching guys I will see you in the next video
-
Sale!
Wireless WIFI Repeater Extender Amplifier Booster 300Mbps
$29.99$14.99 Add to cartWireless WIFI Repeater Extender Amplifier Booster 300Mbps
Categories: Electronics, Wi-Fi Router, Wireless Wi-Fi Extender Tags: 300Mbps, 802.11N, Amplifier, Booster, Extender, mobile wi-fi booster, Remote, WIFI, Wireless, Wireless WIFI, Wireless WIFI Repeater, Wireless WIFI Repeater Extender, Wireless WIFI Repeater Extender Amplifier, Wireless WIFI Repeater Extender Amplifier Booster, Wireless WIFI Repeater Extender Amplifier Booster 300Mbps$29.99$14.99 -
Sale!
Full RGB Light Design Gaming Headset Headphones with Mic
$24.99$14.99 Add to cartFull RGB Light Design Gaming Headset Headphones with Mic
Categories: Electronics, Gaming, Gaming Headsets Tags: Design, Full, Full RGB Light Design Gaming Headset, Full RGB Light Design Gaming Headset Headphones, Full RGB Light Design Gaming Headset Headphones with Mic, Gamer, Gaming, Gaming Headset Headphones, gaming headset wireless, Headphone, Headphones, Headset, Light, Mic, Package, RGB$24.99$14.99 -
Sale!
Wireless BlueTooth Multi-Device Keyboard Mouse Combo
$39.99$19.99 Add to cartWireless BlueTooth Multi-Device Keyboard Mouse Combo
Categories: Electronics, Gaming, Gaming Keyboards, Keyboard Mouse Combos Tags: Combo, Keyboard, keyboard mouse combos, Mouse, MultiDevice, Set, WireKeyboard Mouse Combo, Wireless, Wireless BlueTooth Keyboard Mouse Combo, Wireless BlueTooth Keyboard Mouse Combos, Wireless BlueTooth Multi-Device Keyboard Mouse Combo, Wireless BlueTooth Multi-Device Keyboard Mouse Combos$39.99$19.99 -
Sale!
High Back Leather Executive Adjustable Swivel Gaming Chair with Headrest and Lumbar
$199.99$139.99 Add to cartHigh Back Leather Executive Adjustable Swivel Gaming Chair with Headrest and Lumbar
Categories: Gaming, Gaming Chairs Tags: Adjustable, Chair, computer chairs, Desk, Executive, Gaming, Girl, Headrest, High, High Back Leather Executive Adjustable Swivel Gaming Chair, High Back Leather Executive Adjustable Swivel Gaming Chair with Headrest, High Back Leather Executive Adjustable Swivel Gaming Chair with Headrest and Lumbar, High Back Leather Executive Adjustable Swivel Gaming Chairs, Leather, Lumbar, Office, Racing, Swivel$199.99$139.99 -
Sale!
Professional LED Light Wired Gaming Headphones with Noise Cancelling Microphone
$29.99$19.99 Select optionsProfessional LED Light Wired Gaming Headphones with Noise Cancelling Microphone
SKU: N/A Categories: Electronics, Gaming, Gaming Headsets Tags: Cancelling, Gaming, Gaming Headphones with Noise Cancelling Microphone, gaming headset, Headphones, Headset, LED, Light, Mic, Microphone, Noise, Professional, Professional LED Light Wired Gaming Headphones, Professional LED Light Wired Gaming Headphones with Noise Cancelling Microphone, Wired, Wired Gaming Headphones, Wired Gaming Headphones with Noise Cancelling Microphone$29.99$19.99 -
Sale!
Gaming Desk with LED Lights USB Power Outlets and Charging Ports
$349.99$249.99 Select optionsGaming Desk with LED Lights USB Power Outlets and Charging Ports
SKU: N/A Categories: Computer Desk, Gaming, Gaming Desk Tags: and Charging Ports, Charging, Desk, Desks, Gaming, gaming desk with led lights, Gaming Desks with LED Lights, Home, LED, Lights, Monitor, Office, Outlets, Port, Power, Room, Stand, USB, USB Power Outlets, White, Workstation$349.99$249.99 -
Sale!
Wired Mixed Backlit Anti-Ghosting Gaming Keyboard
$99.99$79.99 Add to cartWired Mixed Backlit Anti-Ghosting Gaming Keyboard
Categories: Electronics, Gaming, Gaming Keyboards Tags: Antighosting, Backlit, Blue, brown, Gaming, Gaming Keyboard, gaming keyboards, gaming keyboards and mouse, Keyboard, Laptop, Switch, Wired, Wired Mixed Backlit Anti-Ghosting Gaming Keyboard, Wired Mixed Backlit Anti-Ghosting Gaming Keyboards, Wired Mixed Backlit Gaming Keyboard$99.99$79.99 -
Sale!
Wireless Bluetooth 5.3 ANC Noise Cancellation Hi-Res Over the Ear Headphones Headset
$119.99$59.99 Add to cartWireless Bluetooth 5.3 ANC Noise Cancellation Hi-Res Over the Ear Headphones Headset
Categories: Electronics, Gaming, Gaming Headsets Tags: 5.3 ANC Noise Cancellation Hi-Res Over the Ear Headphones Headset, ANC, Audio, Bluetooth, Cancellation, Ear, Earphone, gaming headset, Headphones, Headset, Hi-Res Over the Ear Headphones Headset, HiRes, Noise, Wireless, Wireless Bluetooth 5.3 ANC Noise Cancellation Hi-Res Headphones, Wireless Bluetooth 5.3 ANC Noise Cancellation Hi-Res Over the Ear Headphones Headset, Wireless Bluetooth 5.3 ANC Noise Cancellation Hi-Res Over the Ear Headphones Headsets$119.99$59.99 -
Sale!
Wired Sports Gaming Headset Earbuds with Microphone
$19.99$9.99 Select optionsWired Sports Gaming Headset Earbuds with Microphone
SKU: N/A Categories: Gaming, Gaming Headsets Tags: Accessories, Earbud, Earphone, Earphones, Gaming, gaming headset with microphone, Headphones, Headset, IOS, Microphone, Sports, Wired, Wired Sports Gaming Headset Earbuds, Wired Sports Gaming Headset Earbuds with Microphone, Wired Sports Headset Earbuds$19.99$9.99 -
Sale!
150W Universal Multi USB Fast Charger 16 Port MAX Charging Station
$49.99$29.99 Add to cart150W Universal Multi USB Fast Charger 16 Port MAX Charging Station
Categories: Charging Stations, Electronics Tags: 150W, 150W Charging Station, 150W Universal Multi USB Charging Station, 150W Universal Multi USB Fast Charger 16 Port MAX Charging Station, 150W Universal Multi USB Fast Charger 16 Port MAX Charging Stations, 150W Universal Multi USB MAX Charging Station, 16 Port MAX Charging Station, 3.5A, Charger, Charging, Fast, laptop charging stations, Max, Multi, Port, Stand, Station, Universal, USB$49.99$29.99
very nice video and lots of good information !!!
Great and wonderful tutorial series. Thank You very much. I have a quick question. Please how do I update the web app.
I tried loading the session through putty and making a pull request as well as a push request to github but still the web app in not updated
You are my hero
Brad hello.
Will there be a content update as of today?
If we clone a project through a github, will the files in the project change when the project files in the github change?
Thank's
Thanks brad
Thanks for great video. :))
Link COURSE: Full course this project is based on is broken
Actually Vultr is the cheapest VPS out there per value.
I came here to learn about user registration / login. Ended up watching from the first video in the series and stayed until the last video. Very well put together.
Hey if you go to the sources tab I see all the assets not minified. How can I do that?
Hi, I'm new to NodeJS. I'd like to know, is it possible to deploy it on your own server?
Can I still use digitalocean if I am based in South Africa?
wrg
This is a really great video, gave me a basic understanding between running a project locally and having it running 24/7 on a vps. Thanks a lot!
@Brad Traversy what do I do with the .env variables? The documentation states to create a .yaml file with a specific object notating that variable should have SECRET labeled within object in the .yaml file. I'm not sure how to go about this because I've never done anything like that before. I'm new to this and very nervous about submitting the .env variable information without having a specific walk through on how to do this.
"it's not a perfect world" the first time someone makes sense with his words….anyway i MUST thank you so much 'cause you have teached me so much ..thank you from the bottom of my heart
Thank you for the great vid Brad.
Great video..! Thank you.
Can someone help me deploying this on heroku and using mongo atlas
I noticed that when I tried to login with a non-existent user, it gives both "Logged in" and "User not found" messages at the same time when redirected to "/login".
How to fix this?
Im on a VPS and dont have root privileges. Does anyone know how to install libcap2-bin?
Great as usual!
Please do more full apps tutorials,most tutorials never talk about deployment!
I generated the key with wsl . How can I configure it without using PuTTY?
will this work for HTTPS (port 443) ?
Hi Traversy, can you make a video about hosting MERN app
Dang dude, that was like a full course. Your content is amazing.
I want to personally say a big thank you, and I just donated to your cause. This complete video series cost some money on regular online teaching platforms. 2 years later, and I am still learning a lot from this video.. Thanks Traversy.
I need to sent up an express endpoint to listen for webhooks. However, the webhook requires HTTPS. So I've got my domain set up to use HTTPS, but I've already deployed my React App to https://mydomain.com . How do I
a) deploy my node in addition to the react app, so it can listen at https://mydomain.com/hook as endpoint
OR
b) install SSL on my entire server => then I can just tell the webhook to post to https://xxx.xx.xxx.xxx/hook as my endpoint
man thank you so much
THIS IS EXACTLY WHAT I WANTED, THANKSSS FOR THE VIDEO !
You are awesome Brad!!!