Blog using the MERN Stack Part 1 - Starting the project
22/01/2021
Introduction
We'll be creating a blog using the MERN Stack.
The MERN Stack stands for:
MongoDB
ExpressJS
React
NodeJS
MongoDB is a NoSQL database. It's a general purpose database that uses BSON (a JSON like format) to store data. It can be incredibly powerful when used properly.
NodeJS an asynchronous event-driven JavaScript runtime.
ExpressJS is a web framework that uses NodeJS. it incredily easy to make routes for API Calls.
Lastly, ReactJS is a powerful frontend library made by Facebook. It makes everything pretty.
Prerequisites
You'll need to install a couple of things:
the lastest stable version of NodeJS (currently v14.5.2 at time of writing)
Access to Visual Studio Code from the terminal
Make sure you have node successfully installed by running:
Make sure you have npm successfully installed by running:
You can use Node Version Manager (nvm) to install different versions of Node and to switch between them.
The Node Package Manager (npm) should come installed with NodeJS.
I am using Windows Subsystem for Linux 2 (Ubuntu 20.04 LTS) so if you are following along in another distribution, your console commands might be different (but you probably knew that)
Create a parent directory
We want to create our parent directory which will house both our frontend and backend. So the plan is to have:
Blog
Client
Server
I was using WSL for Windows. My linux distribution is Ubuntu 20.04 LTS.
Go ahead and go into that folder:
First, create your Frontend
For the front end of our app, we will be using React. Go ahead and install create-react-app globally in node. We do this by running:
This creates our React app. Open it in Visual Studio Code.
The folder structure is:

client
node_modules directory
public directory
src directory
.eslintcache
.gitignore
package.json
README.md
yarn.lock
Initialize a git repo in this folder.
Cool, we're done here for now.
Second, create your Backend
Change directory back to your parent directory:
In the blog_mern folder, create your backend folder
Go into your server folder with:
Initialise your code with npm init :
Make sure to set your entry point as app.js
Open Visual Studio Code:
This should open the empty folder in Code. Create a file called app.js.
Your folder structure should look like:

server
app.js
package.json
Initilise a git repo:
Conclusion
Inside our blog_mern parent folder, we have two folders: client and server. Both are git repos
blog_mern
client (git repo)
node_modules directory
public directory
src directory
.eslintcache
.gitignore
package.json
README.md
yarn.lock
server (git repo)
app.js
package.json
In the next tutorial, we will learn how to implement CRUD on the backend.
Last updated