Installing Basic Software Requirements

The first lecture in a MERN stack movie review app series, walking through installing Node.js, VS Code, and Express, then setting up basic routing in an MVC folder structure.

36:04 video4 min readWatch on YouTube

Starting a full stack application means getting the right tools installed before a single line of application logic gets written. This lecture opens a series on building a MERN stack movie review app, where users will eventually be able to upload movie trailers and other users can rate and review them, and it walks through every piece of software needed to get there.

Checking for and installing Node.js

The first requirement is Node.js. Before installing anything, it's worth checking whether it's already present by running node -v in the command prompt. A version number means Node is installed; an error saying the command isn't recognized means it needs to be installed. The video recommends downloading the LTS, or long-term support, version rather than the current release, since the current version can carry more bugs. After downloading, the installer walks through the standard steps: accepting the license agreement and choosing an install folder, with the default Program Files location being a safe choice for most people.

Setting up VS Code

Next comes a code editor. VS Code is used throughout the lecture, though any editor works, including alternatives like Atom or Sublime Text. The installer is downloaded from the VS Code site, matched to the operating system, and installed with default options, including creating a desktop shortcut and adding an "Open with Code" option in Windows Explorer for convenience.

Initializing the project with npm

With the tools in place, the next step is turning a plain folder into a Node.js project. Running npm init inside the project folder walks through a series of prompts: package name, description, entry point (kept as the default index.js), and author name. Confirming these creates a package.json file that records the project's metadata. A quick console.log(1 + 1) inside index.js, run with node index.js, confirms that JavaScript is executing correctly in the environment.

Installing and running Express

To move beyond plain JavaScript and build a web application, Express is installed with npm install express. This creates a package-lock.json file and adds Express as a dependency inside package.json, along with a node_modules folder containing the libraries Express depends on. A minimal server is set up with const express = require('express'), const app = express(), and app.listen(8080, ...) to start listening on port 8080. Running node index.js starts the server, and visiting localhost:8080 in a browser initially returns a "cannot GET" message, since no route has been defined yet for that path.

Adding routes and moving to an MVC structure

A basic route is added with app.get('/', (req, res) => { res.send('<h1>Homepage</h1>') }), and a second route for an About page demonstrates handling multiple endpoints. As the application grows, cramming every route into a single index.js file becomes impractical, which is where the MVC, or model-view-controller, pattern comes in. Since this is a backend-only application, the focus is on models and controllers rather than views. Separate routers and controller folders are created, each containing a user.js file. The router file imports Express's router module with express.Router(), defines routes like router.get(...), and exports the router with module.exports = router. Back in index.js, that router is imported and wired in with app.use(userRouter), keeping the main file clean while routing logic lives in its own module. The controller file then holds the actual functions that respond to each route, like an initial createUser function that sends a basic response.

Testing with Postman and installing MongoDB

Since browsers only send GET requests by default, testing a POST route requires a dedicated tool. Postman is installed for this purpose, allowing requests of any type, GET, POST, PUT, PATCH, or DELETE, to be sent directly to the server. A POST request to localhost:8080 confirms that the router and controller are correctly wired together. Finally, MongoDB is set up by creating a free account through MongoDB's website, which provides free hosting for the database the application will use in later lectures.

Key takeaways

  • Check for existing installs with node -v, npm -v, and npx -v before reinstalling anything.
  • Prefer the LTS version of Node.js over the current release for stability.
  • npm init creates the package.json file that defines a Node.js project.
  • Express is added as a dependency with npm install express and used to define routes and start a server with app.listen().
  • Splitting routes and logic into separate routers and controller folders follows the MVC pattern and keeps index.js manageable as the app grows.
  • Postman is needed to test non-GET requests like POST, since browsers only issue GET requests by default.

Who this is for

This lecture is for beginners setting up their first MERN stack project from scratch, and it works well as a starting reference for anyone about to build a full stack Node, Express, React, and MongoDB application step by step.

Full transcript(auto-generated, with timestamps)

[0:03]Hello everyone in this video lecture series I'm going to teach you how to create a a movie review app where the user can actually uh upload a movie trailer and the other users can actually give the review of and rating of the movie and uh the to create this movie review app I'm actually going to use the M Stack that is DB expressjs reactjs and nodejs I really excited to start this course so to start the first to start the course we need to actually install all the prerequisite uh softwares to actually run the application and the first we need to install node js before

[0:55]Installing nodejs we can actually check if we already have nodejs installed in our computer to check that you can actually click on Comm command prompt and give this command node hyph V if you get a version number like the like I'm getting then you it means like you already have node installed in your computer if you don't get any number like this that then that means you have to install node into your computer if you don't have node you'll get an error saying uh node command is not recognized so if you get an error like that then no problem just go to Google Search and enter node

[1:40]P and click on this the first link there is actually two versions available one is the current version that is the uh latest version that was released but it might have some bugs so I would always prefer to download the LTS version which is the long-term uh support So download it so after downloading it go to the downloads folder the in installer would have actually downloaded downloaded just double click on it it is going to just compute the space requirements to actually so install noj in our computer next click on next next accept the license agreement next and this is where it is asking you which folder you want to

[2:38]Install the node js you can install it anywhere in your system but I just prefer to install it in the default folder that is the inside program files click on next next next and it will actually ask you to install over here as I have already installed noj in my computer I'm not going to reinstall it so you can just go ahead and install it and it's pretty much a basic step then finish it then after installing nodejs we we have to install uh vs code in our computer so to install vs code again go to Google Search and write vs code and you'll get the first L link

[3:29]Click on the first link and you'll get the download for Windows section download it for other Mac OS or Linux systems you can actually go and uh click on the stable version of the uh Mac OS or Linux system now I'm going to download it for Windows and it is now getting downloaded yeah and if you go to download section uh folder and double click on the installer vs code installer it will prompt you to the next steps yes yeah accept to the license agreement next create your own desktop icon so that we can actually uh in the end you can actually have a shortcut in

[4:28]The desktop and uh open with code add open with code Windows Explorer everything click on next uh I have already installed it in my computer but you can just click on install over here uh and install it in your computer and I want to add that I'm just using vs code you can use any text editor that you are comfortable with if you're Comfort already installed atom and you're comfortable with that text editor you can go ahead and use that text editor or a subline txt anything that's that you prefer so now go ahead and open the uh text editor and now we are inside our project

[5:20]Folder from here we are I'm going to open my terminal and actually route it to the project folder that is for formates inside my desktop just give this command CD and Route it towards that project folder now uh now that I'm inside the project folder I forgot to add one point is like after checking for the node version you can all when you install node you also get get two more things installed that is npm and and npx you can check that version to npm version will give you the npm that is installed in your computer that is like for me it is n 8.5.2 and npx

[6:18]Version yeah that is also 8.5.2 so this to will be by default installed when when you installed uh nodejs in your compter computer now if I give the command npm in it it will actually create a folder for me uh uh that that folder and make it into an node js project folder just c on it npm in it yeah you're getting this just second and I'm going to keep the package Dre as the default project and then description I'm saying education you know video and entry point I'm going to keep the default as index.js uh as of now we don't have any test command and get repository also we

[7:31]Haven't initialized as of now but we in later on in this course we will create a we might have to create a get repository to push our all our code into the G GitHub repository which we will explore in later videos no so and author name you can give any author name I'm giving my name and that's it finish this will actually create the package.json file in your project folder by default see the information you can see the information that we actually entered over there is reflected over there author is subash and the main is the index.js file okay so now uh we have to create a

[8:25]File uh Javascript file index.js file exactly it has to be with this name and inside that index.js file we can write our JavaScript code to start with it I'm just going to uh give the console.log uh so that we can see how if it is actually printing the results and be pretty sure that JavaScript is working in our computer log just a basic command 1 + one we should get two printer in our terminal open the terminal and node index.js it's giving it is printing out two it's 1 + 1 if it if you give it is

[9:35]Like 10 + 1 and save it it will actually now give out 11 yeah that's this pretty much some up that nodejs is actually working and we have actually successfully created our first JavaScript code okay after but in console.log if you give window which is actually a key keyword but if you check it and run it it will give an error yeah because we don't have an windows or an app that is that we have initialized till now so to do that the inm stack you would have heard like the express JS we have to install Express in our computer uh to install Express JS in our computer

[10:34]Cck on this and expressjs is a web application framework see this is the command npm install Express is the command that we have to run in our uh terminal but uh inside our project fold it should be inside our project file that is a main thing that I should add if you want you can also give just npmi instead of install Express and it will actually install Express into project forum just waiting for the command to be completed now if you check into our project folder it would have created package lock. Json and uh inside package.json that was already created it would have added the

[11:44]Dependencies as Express 4.8.2 that that is basically because we have installed Express and it is a dependency in our JavaScript project and this package lock. Json is uh the by default uh written by the express JS if you don't understand what and each and every uh thing that is meant in this uh section please don't play with it let it have it be in default uh uh settings this node if you check a folder uh node modules over here this is what what actually Express has actually given uh installed in our Compu computer and this has given us access to lot of libraries so that this we can use this Express JS

[12:41]Framework in uh to create our application okay so inside index.js how to use express I'll actually show you the right now you actually basically have to give const Express equal to yeah require Express uh then you have to give the command uh const app equal to express it will actually start the express uh it will actually create an express application for us and then app.get uh first we'll give app do listen to Port we'll set our uh local Port as 8080

[13:58]And console. log server is running on port 8080 this is basically what I I just wanted to print it in console.log to actually check if our uh Port has application has started and listening to the this port this is the basic command and now I'm going to start the application node index.js if I give node index.js it will actually start our application Express server server is now run if you can see Server is now running on Port 880 that is the printed in the console and now if you go go and open your browser and give Local Host 8080 you will get cannot cannot get

[15:04]Because we haven't given given any uh uh router links till now that is why we are getting like this if you actually listen to any other Port other than 8080 it will give you an error like unable to connect but that is not the same error that we are getting it we are actually able to connect to the server right now but that is no uh router that is uh uh API router that is actually routed to this page that is the only problem till now this is itself actually a success right now now we will actually create an uh AP AP router to the G the get for that we have

[15:50]To give app. listen app. get sorry which means it's actually a uh get request and then request come on response respon and inside over here I'm going to say give rest. send uh I can I want to type a HTML basically you can send an HTML so that it will be uh reflected in the web application H1 yeah header one and I'm going to print homepage that's a nothing it's pretty much basic uh and now you to actually uh show

[17:04]It in the application you have to first fill the application for that press control C and you will kill the application and you have to restart and run it again not index.js now server is again running in port 8080 if you go go ahead and see over there and if you reload it you'll get the homepage printed over homepage shown in the HTML page over here now uh to test it or not just one on the default route if we want to add one more router We'll add it like one more think um we'll say make about we let's create an about page and we'll name it like about page

[18:04]Then if we uh restart our application yeah now we are in homepage now if I give about it is show about page can see see it right over here so that's it we have actually successfully started and created a basic web application in nodejs it's as simple as that now the now we have to start creating a MVC pattern for our uh application why what is the requirement for an MVC uh pattern is when it is uh when the web application as simple as only these two get request it can be handled within one uh project folder project file but we we cannot uh handle a this much big project inside

[19:10]One uh one file called index.js so we are actually uh we need to follow MVC patterns so which is like model view controller and this is just a backend application so we are not going to work on the view view part this this is going to have only the models and controllers so to St work on that I'll actually explain what is it in detail as we uh progress in the lecture uh to show we need to create two more folders and that is routers another one is not inside routers it's controls inside controller and router we have to create a file create it I'm

[20:19]Actually going to in our application anyway we basically want a user right to create user uh we are going to just uh so we are creating a user.js inside the router folder yeah and the same you have to create user.js inside controller folder so that that is where how we map between the router and the controller to find out which uh JavaScript uh uh code controller is actually responsible for this specific router so I'm going to create a file inside the controller JS yeah in this user to actually uh use this user.js we cannot actually export the complete app from uh index.js to user.js in routers

[21:27]Right but we have to use the routers that is actually defined in user.js to actually do that step what we have to you do is H I will actually have an user router because we are that is routing to the router user.js file inside routers user router equal to require the the this period over here actually represents that current for folder working folder slash route slash user we don't need to give JS over here it will actually find the JavaScript application can understand it is the user do JS within after this we have to also give app. use we can basically remove this two commands as we are going to

[22:39]Give all these commands inside our routers and controller folders okay so app dot use user router it and so inside our user.js inside our routers user.js we have to give the const plus equal basically same command to actually use the express JS her also and then we also have to import the router uh express. router uh module so router equal to express. router we are basically importing that router module

[23:51]Uh function into our uh const into a constant uh router variable after that you have to give router dot get this get is because it's a get uh get API call if it is post or put or delete will change accordingly this now I'm just going to use get because we use the same get or here that we can actually copy there and paste it over here copy there over there and paste it over here and just remove all both these get from here and now we are just actually instead of exporting all the application we are

[25:02]Actually just exporting the router from here and that is actually imported there in the application where app. us is using the user router okay so I'm going to uh give module. exports equal to router this command will basically export our R router over here to the main application so now if I give this K this and run it again no index.js module not one small just okay sorry I have by mistake I instead of routers have given routes as the uh directory name or here so that's I'm

[26:15]Just rectifying that error routers r or now let me just run the commment the server is now running on port 8080 and if you go here and actually remove this about because we have removed the about API you are basically getting the same result home page but now we have actually changed all the code from our uh index.js to router routers so we can have basically have many routers user router item router movie router and review router that we can have various number of routers which which is so that and we can all we can use all the routers inside our index.js so that our code will be

[27:13]Structured in an MVC pattern so but this this control folder is still now empty right we haven't used the controller folder so what is the use of the controller is to actually controllers will have the F functions inside the uh user.js which router is just a basically to uh assign from the function called uh assign the fun which function should give the result for the uh request that we got from the uh get API call so get or post or uh the AP call that we get okay so I'm going to go go ahead inside my router.js and we are actually going to change this

[28:06]Into control this Dot request come on response on respond rest. send basically the same thing that we uh had over here that was basically the page right so we will have the same thing over here in the

[29:18]Controller or we can have it like create users or any anything like that so that and now we are going to use this controller inside our router e create yes sir this time we are actually going to use a post request because while creating the uh use before that I'm just going to explain the difference between uh get API call and a post API call in a get API call we actually send all the uh parameters for the request with the get and in post APA call we don't send the parameters

[30:28]Uh with the uh AP with the head it will separately present in headers Json which I will actually explain it to you over the course just uh to start off with I have I'll just change it to post and if you check if we rerun our application the application is running fine the server is running on port 8080 but if we go and check it in browser it is again giving the same uh cannot get slash uh error because browser actually basically send s get request to our s Express server but how to create a post uh request to exess server I will actually EXP explain it more to for that

[31:30]We actually need a need a to install a software called Postman for that give uh Google search Postman you'll have a postman a APA platform you just have to sign up for free over here and actually download it for the windows version and create it I have basically downloaded the already downloaded Postman to my uh computer you can actually I'll show you the post just taking a minute yeah yeah just this is basically how a post will

[32:40]Work and we can create a new AP call and look over here you can actually list down all the types of EP calls that we can send to This Server get post putut patch delete Etc so we have to make a post a call Post Local Host HTT HTTP colon SL Local Host colon 8080 and if we give send send if we are now sending the request see it is returning the create user uh T tag that we actually added to here so yes now if we can verify that our controller and router is perfectly working and we have actually basically set our pro project folder uh we can

[33:47]Actually start creating our uh application from the next lecture but before that the last uh uh uh after that we need to install is mongod DV it is pretty much basic the basically the same steps go to Google Search click on mongod DV search for mongod DV it's going to create uh it's going to come over here click on mongod DV first link some time yeah start for free uh every everything for hting it locally is completely free in mongodb can do start for free start free L up with Google

[35:15]Yeah this will actually I have I already have created in my own account so it is it has directly uh rerouted me to my dashboard if you you just have to create your own free uh free account and you'll actually be directly uh routed to this page so that's it for my first video I hope you liked it I'll upload my we'll actually basically start building our movie review application from our next lecture thank you

More videos

Humanitarians AI Lyrical Literacy Project