Node.js & Express From Scratch [Part 1] – Intro & Environment
- December 25, 2023
- Posted by: MainInstructor
- Category: C Go JavaScript Node SQL Web Development
Video Title: Node.js & Express From Scratch [Part 1] – Intro & Environment
Hey what’s going on guys welcome to a new series now for those of you waiting on laravel the premium course the crash course and the youtube project should all be released within the next few weeks so in this series what we’re going to be doing is creating a nodejs and
Express application from absolute scratch so the idea of this series is to be very very beginner friendly and to be kind of a continuation off of my node.js for beginners crash course alright so after people finish that this gives them the opportunity to actually create a
Project with node and express in a bunch of other technologies ok so this will be from absolute scratch we’re going to start on a machine that doesn’t even have no js’ or Express or MongoDB installed we’re going to go through the installations we’re going to set up the
Environment and then there’s going to be no generators no copying and pasting the goal of this is to write and explain every line of code so that you guys can really grasp what’s going on as opposed to just watching a demo of an app being built alright so if you have a little
Experience with node and express in MongoDB that’s great if you don’t even know what those are I would suggest watching these three videos here they’re there on my channel I was just watching those before tempting the course or the series alright now as far as the application goes it’s going to be very
Simple in terms of functionality at least at first we’re going to be able to create read update and delete articles stored in a MongoDB database from our node and Express app all right so let’s take a look at some of the technologies that we’ll be using and learning so
Nodejs and npm nodejs is a JavaScript runtime and server-side technology and it comes with NPM which is node package manager and this is used to install modules like Express and thousands of others okay so Express is a back-end framework for building powerful applications web applications MongoDB which is a no SQL database
Mongoose which is an ORM or an object relational mapper and this allows our application to interface with MongoDB we’ll be using the pug template engine for our views pug is formally known as J we’ll be installing bootstrap a few videos in and we’re going to use Bower
For that which is a front-end package manager similar to NPM we’ll also do a little bit of jQuery and Ajax to make delete requests to our server alright so I try not to mention this stuff too much but I do have a patreon if you guys want to support this channel directly even
$1.00 per month is greatly appreciated if there’s enough people that can help out then I’ll be able to do this stuff full-time which is my goal and I’m also working on some exclusive content and perks for patrons for one-time donations I have a paypal dot me account and then
If you’re interested in premium courses I have affiliate links at traversée Mediacom slash edge’ wanax courses alright and I will be creating my own courses very very soon so that’s it guys let’s go ahead and get started on this project and hopefully you enjoy it alright guys in this video we’re going
To be setting up our environment so we’re going to install a couple things to build our application now I’m using Windows because I want this to be completely beginner friendly and I know that a lot of people that are just getting into web development and so on maybe on Windows alright
But this is completely cross-platform all the code we write everything it doesn’t matter what system you’re on alright so we’re going to install a couple things of course we need nodejs and nodejs is a JavaScript runtime if you have no clue what nodejs is I would suggest watching my node for beginners
Video we’re going to install that that also comes with NPM which is node package manager and that’s a command line tool that we can use to install different modules like Express and Mongoose and so on alright we’re also going to need a database and we’re going to use MongoDB
Long would you be is a no SQL database if you want to learn more about I’d suggest my MongoDB in 30 minutes video I also just did a video called a guide to know SQL databases if you want to learn more about no SQL in general
We’re also going to be using atom which is a text editor this is what I’ve been using for the most part lately and it’s it’s a really nice editor it’s by github it’s very very well as far as looks and themes and it also has a bunch of packages that you
Can install that will help you with development so we’re going to install that and then sensitive on Windows we need a better command line because the the standard CMD command line in Windows is garbage so we’re going to be using git bash okay so this right here get SCM
Comm you can download it it’s going to download the git version control system along with the command line tool called git bash alright so let’s get started first thing we’ll do is install nodejs so we’re going to just go ahead and click here we’re going to get the
Recommended version which is at this time six point ten point three and that’s going to just be an installer we’ll just go through it quickly alright so let’s open it up and just go through this we’ll click Next and it’s going to go into your Program Files if
You’re on Windows click Next and install alright and it’s as easy as that nodejs and NPM is now installed so next thing we’re going to do is we’re going to install MongoDB so let’s go ahead and go to C download and there’s a few steps
That we need to do here some of which are in the command line but it’s not too bad so we’re going to grab the yeah windows 64-bit 2008 and later and that’s going to download the MSI file so this is another installer that we need to go
Through and it is a hundred and forty eight megabytes so it may take a couple minutes to download so once it’s downloaded just open it up and we’re going to go through this next and I’m going to click custom right here because I want to change the install path by
Default it’s going to be Program Files MongoDB server and then the version I don’t want that I want it to be right in the C Drive so let’s go to local C Drive and what I’ll do here is create a new folder called MongoDB alright and that’s where
We want this to be installed c / MongoDB will click Next and then install and it’s going to go through the setup okay so we’ll click finish now there’s a couple extra steps we need to take we need to go into that folder that we just
Installed it in so for me it’s going to be C Drive MongoDB and we’re going to create a folder here called data alright and then inside the data folder we’re going to create another folder called DB this is where all of our data will be stored now we have to also create a
Log-log folder so it’s a new folder log alright and then we need to open up a command line and I haven’t installed git bash yet so we’ll just use the standard command prompt so it’s a CMD and we’ll run that as administrator okay and then let’s see so I’m going to navigate to
That folder so we want to go to CD MongoDB and we actually want to go in the bin folder alright if we look at what’s in there oops can’t do that there is a vis MongoDB XE that’s the main program so we need to run that with
Some options or some flags so let’s say D and then we’re going to do – – let me make this a little bigger so you guys can see it see I haven’t done this in a while font let’s make it 28 there we go alright so D directory oops why
Isn’t that typing directory and it’s going to be per DB okay directory / DB and then – – DB path and then we want to define that data path that we created so it’s going to be in your MongoDB MongoDB folder slash data slash the B okay that’s the folder
We just created so what we’re doing is we’re specifying the database path as that folder all right or that location then we need to specify the log path okay so that is going to be C slash MongoDB slash log and it’s going to be a file called Hmong dot log and
It’ll create that on its own then we just want to add a couple more flags here – – log append we also want to do dash dash rest and dash dash install ok and then that will install it as a service so that it runs in the background we don’t have to
Manually start and stop at all the time and so on so let’s go ahead and click enter and next thing we want to do is start the MongoDB service so to do that we can say net start MongoDB okay now it says the services started successfully so that’s
It MongoDB is now installed it’s running and we can now interact with it from from our application so let’s go ahead and close that up and then we’re going to move on we’re going to install Adam which is the text editor so I’m just going to click download all right so
Once that’s done we’re just going to open that up and the Adam installer is is really weird because it does everything behind the scenes you’ll see this little splash screen and then once it’s done it’ll just be installed on your system alright Adam is it Adam was actually created with JavaScript it uses
Electron which is a JavaScript framework that allows you to build desktop applications with JavaScript which is really cool and I do have an intro to electron video if you’re interested in that all right so it’s installed Adam and started it up I’m just going to get rid
Of this stuff this is just because I had it installed previously so let me just remove that project and then this is just kind of a welcome screen if you want to open a project install packages and so on but we’re going to close all that up and will most likely install
Some packages but we’re going to do that later on all right so we can close that for now and then we’re going to move on to install git and get bash so let’s click this download for Windows if you’re using a Mac you can go to download slash Mac and get this same
Same program all right so that’s going to start it’s only 35 megabytes so it shouldn’t take too long to download all right so we’ll open that up and we’re just going to go through this it’s going to install it in your Program Files and then for this we’ll just leave all the
Defaults and then when you see this option I always choose this because this will add optional UNIX tools to the regular Windows command prompt so for instance LS you saw that I tried doing that in the regular command line and it didn’t work so it’ll add that it’ll add
A whole bunch of stuff so I always choose that and then for the rest of this stuff we’re going to leave the default open SSL library that’s good windows style click Next Next and enable filesystem caching we’ll leave that credential manager we’ll leave that and we’ll click install all right so that’s
All set now let’s go ahead and click launch git bash and then this is the command-line tool so we can make this bigger with can holding ctrl and then scroll the mouse wheel and just to check to make sure that node is installed we can say node
Dash B you can see we have version six point seven point three and we can also say NP – B and we have version three point seven point ten so that’s it for setting setting up our environment in the next video we’re going to start – to build
Out our application will create our package JSON file and we’ll go from there
-
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
Hello, thanks for very useful tutorials
i wanted to let you know "COURSE: Full course this project is based on" link is not working (in description)
wait, you watch your own crash courses?
when I get a job you can have my dollar for life man <3
This is exactly what i needed thank you so much for this tutorial.
10:04 I got an error with net start mongodb, solved it by going to mongod.cfg (in bin), open with Notepad and commented the last line of code (#mp), now net start mongodb works
when i check for node-v on windows cmd it gives me version as it is installed correctly but after i installed git bash it returns "
bask: node: commandt not found" when i execute node -v
you are a hero, a great example of human being
Is this still relevant os of April 2020? Or should I watch a more updated tutorial?
Be blessed by the Divine appreciate your approach.
stuck with the problem of –rest. still no proper answer from Traversy Media owner. currently, not really a beginner friendly series at all.
I did 4 years of computer science in university! not a single professor was 1% as good! thank you!
Hi, I need help in node js. Can you please tell how can I select CSV file from frontend after selecting file I want to store CSV file data in MongoDB collection
sir if you have prepared tp publish for us – a scratch dashboard tutarial on Bootstrap 4 and NodeJS, we will be very greatfull to you. please
Traversy Media is the best 😀
Would love to see a tut with sqlite3 instead of Mongo.
first i got an error regarding that –rest command so i removed it but after that when i tried to use the net start mongodb command i got another error that says "the service is not responding to the control function mongodb" please any help?
Getting error "the service is not responding to the control function" upon net start mongodb
Any help?
Thank you so much for the video. I have faced an error in installing mongodb, "failed to start mongodb due to privilege rights", I have tried many options like installing using cmd under administrator privilege, updated .Net framework to the latest, till the error was there. What I have found is when you change the database location from program files to any other location, it will not start as windows service. So kindly install mongodb in program files itself.
Keep doing such amazing videos!!!
http://www.traversymedia.com/course/p...
doesn't work
You need this for mongoDB to run in 2019 https://support.microsoft.com/en-us/help/2999226/update-for-universal-c-runtime-in-windows
your node js crash course using vscode but here youre using atom. should I use atom for this tutorial or its okay to use vscode? is there any significant difference?
The –rest parameter was removed in MongoDB 3.6. Write the command without –rest and everything will work fine
Just installing node had me frustrated. I got a missing DLL error. Had to disable antivirus and then clean out the temp folder in order to install it. Then after installation running npm on the command line would generate errors that I had no clue how to solve. Really left a bad impression for me.
very thanks.
"The windows command prompt is garbage." I never subscribed to a channel that fast.
is the same when you connecting mysql using express as connecting databases with mongodb?
it SUCKS for this to be on Windows and not Linux. I know this is for beginners but that's not like it should be for stupid people.
I am on following your video, these are really awesome, thanks a million. Currently there is Deprecation warning on mongoose connect, but solved use as follow:
mongoose.connect('mongodb://localhost:27017/nodekb', {useNewUrlParser: true});
after: net start mongodb
got: The service is not responding to the control function.
ideas?
Thank you, teacher
I'm getting drowsy in your tutorials by the way you are very great man, kudos to you, you are my favorite instructor here in youtube. Thanks, just suggesting to make more energetic in terms of speaking.
I'm more familiar with Rails because of various projects I'm helping out with, but because I'm a windows user and want to make my own projects, Node.Js and Express seem way more efficient. This series gives me an idea on where to start. Thanks!
Can someone please tell me what does " –rest " do?
I get I get ''F CONTROL [main] Failed global initialization: FileNotOpen: Failed to open "c:mongodblogsmongo.log" when I run this command'' when trying to run c:mongodbbin>mongod –logpath c:mongodblogsmongo.log –dbpath c:mongodbdatadb –directoryperdb –install. What to do?
how to fix this error
$ npm start
> nodekb@1.0.0 start C:nodejsProjectnodekb
> node app
events.js:183
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE :::3000
at Object._errnoException (util.js:1022:11)
at _exceptionWithHostPort (util.js:1044:20)
at Server.setupListenHandle [as _listen2] (net.js:1367:14)
at listenInCluster (net.js:1408:12)
at Server.listen (net.js:1492:7)
at Function.listen (C:nodejsProjectnodekbnode_modulesexpresslibapplication.js:618:24)
at Object.<anonymous> (C:nodejsProjectnodekbapp.js:16:5)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nodekb@1.0.0 start: `node app`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nodekb@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:UsershussaAppDataRoamingnpm-cache_logs2018-04-30T14_57_06_479Z-debug.log
hi,
"net start mongodb" not working on ubuntu…
please help!!!
Subscribed, Liked & Shared … Best online tutor … Thanks a lot.. god bless you….!
Hey traversy! What's the solution of "Error parsing command line: unrecognised option '–rest' try 'mongod –help' for more information" Thanks 😀
If you're getting an error for the –rest option, just delete it. –rest has been depreciated in the version 3.6. Once you delete –rest from your path, run net start mongodb and services should start running. Also don't forget to have admin permissions set up for non admin user accounts.
Brad Sir, Amazing sessions.. Can you please share the notes as well for the above video as well as other videos like reactjs etc.
I'm surprised Travis hasn't responded to the problem people are having with –rest. He's always very detailed about the steps he writes so we understand why we're doing it his way. I didn't find info on –rest online so I'm going to skip that flag and hope for the best.