Creating a MEAN Stack Project from Scratch: Building an Angular 15 Blog Application with Testycodeiz

Posted by

Mean Stack Project from Scratch

Mean Stack Project from Scratch

In this tutorial, we will create a blog application using the MEAN stack – MongoDB, Express.js, Angular, and Node.js. This tutorial is for beginners who want to learn how to build a full-stack application.

Step 1: Setting Up the Environment

First, make sure you have Node.js and npm installed on your machine. You can check if you have them by running the following commands in your terminal:

node --version
npm --version

If you don’t have Node.js or npm installed, you can download and install them from the official Node.js website.

Step 2: Installing Angular and Express

In your project directory, run the following commands to install Angular and Express:

npm install -g @angular/cli
npm install express body-parser cors mongoose

Next, create an Angular project by running the following command:

ng new mean-blog

Step 3: Creating the Backend

Create a new folder called “server” in your project directory. In this folder, create a new file called “server.js” and add the following code:

const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const mongoose = require('mongoose');

const app = express();
const PORT = 3000;

app.use(bodyParser.json());
app.use(cors());

app.listen(PORT, () => {
  console.log('Server is running on port ' + PORT);
});

Now, run the following command in your terminal to start the server:

node server/server.js

Step 4: Creating the Frontend

Open a new terminal window and navigate to your Angular project directory. Run the following command to start the Angular development server:

ng serve

Now, you can open your browser and navigate to “http://localhost:4200” to see your Angular application running.

Step 5: Connecting to MongoDB

In your server folder, add the following code to connect to MongoDB:

mongoose.connect('mongodb://localhost:27017/blog', {
  useNewUrlParser: true,
  useUnifiedTopology: true
});

Make sure you have MongoDB installed on your machine. You can download and install MongoDB from the official website.

Step 6: Adding Testycodeiz

Lastly, to add Testycodeiz for testing purposes, run the following command in your project directory:

npm install --save-dev testycodeiz

Now you can write tests for your application and run them using Testycodeiz.

Congratulations! You have successfully created a blog application using the MEAN stack. Happy coding!

0 0 votes
Article Rating
10 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
@TestyCodiez
6 months ago

Learn Complete #Meanstack

@prashantrai4698
6 months ago

First hour is completed and thanks a ton bhai..
People who are watching these video now have to use async await now as callback in nodejs is deprecated and findIdAndRemove is also not available instead use findOneAndDelete.

@ayeshdev
6 months ago

need more projects on mean stack

@calisthenics-
6 months ago

Very Helpful thank you so much ❤❤❤❤❤❤❤❤

@kumarkushagra669
6 months ago

git link is not working

@dev_ash-qh8sr
6 months ago

Can you show deployment ?

@SaurabhKumar-cr4yr
6 months ago

You help me a lot in for learning Angular in better way 🎉❤❤❤

@SaurabhKumar-cr4yr
6 months ago

Gd morning bhaiya❤❤

@athiragopi6070
6 months ago

good morning

@athiragopi6070
6 months ago

Angular design part ?