Building a Blog with Express.js

In this lesson, we are going to create a blog application using Express.js and the MVC architecture.

Creating a new Express project

Let's start by creating a new Express project. Create a new work directory using the following command:

bash
1mkdir blog
bash
1cd blog

Initialize a new Node.js project:

bash
1npm init

A new package.json file should be created. Add "type": "module" to it so that the packages can be imported as ES modules.

json
1{
2  "name": "blog",
3  "type": "module",
4  "version": "1.0.0",
5  "description": "",
6  "main": "index.js",
7  "scripts": {
8    "test": "echo \"Error: no test specified\" && exit 1"
9  },
10  "author": "",
11  "license": "ISC",
12  "dependencies": {
13    "express": "^4.19.2",
14    "pug": "^3.0.2",
15    "sqlite3": "^5.1.7"
16  }
17}

Install packages express, sqlite3, pug, and multer:

Wait, there is more!

You need an account to access the rest of this lesson. Our course is 50% off for limited time only! Don't miss the opportunity!

🎉 Create an Account 🎉