Installing MongoDB, Express, Angular, and Node.js: A Step-by-Step Tutorial

Installing MongoDB, Express, Angular, and Node.js (MEAN Stack)

๐Ÿ”ง 1. Install Node.js and npm

Node.js includes npm (Node Package Manager), which you'll use to install other packages.


➤ Steps:

Go to the official website: https://nodejs.org


Download the LTS version (Recommended for most users)


Run the installer and follow the setup instructions


✅ Verify Installation:

bash

Copy

Edit

node -v

npm -v

๐ŸŸข 2. Install MongoDB

MongoDB is the NoSQL database you'll use for your backend.


➤ Option A: Install Locally

Go to: https://www.mongodb.com/try/download/community


Choose your OS and download the MongoDB Community Server


Follow the installer prompts


Ensure you check the box to install MongoDB as a service


✅ Verify Installation:

bash

Copy

Edit

mongod --version

➤ Start MongoDB:

bash

Copy

Edit

mongod

MongoDB runs on mongodb://localhost:27017 by default.


➤ Option B: Use MongoDB Atlas (Cloud)

Visit: https://www.mongodb.com/cloud/atlas


Create a free cluster and copy the connection string


๐ŸŒ 3. Install Angular CLI

Angular CLI is a tool to create and manage Angular projects easily.


➤ Install Globally:

bash

Copy

Edit

npm install -g @angular/cli

✅ Verify Installation:

bash

Copy

Edit

ng version

➤ Create a New Angular App:

bash

Copy

Edit

ng new my-angular-app

cd my-angular-app

ng serve

Access your app at: http://localhost:4200


๐Ÿš€ 4. Install Express (with Node.js)

Express is a minimal web framework for Node.js.


➤ Create a New Directory:

bash

Copy

Edit

mkdir my-express-backend

cd my-express-backend

npm init -y

➤ Install Express and Useful Packages:

bash

Copy

Edit

npm install express mongoose body-parser cors

➤ Create a Simple Server:

server.js


js

Copy

Edit

const express = require('express');

const mongoose = require('mongoose');

const bodyParser = require('body-parser');

const cors = require('cors');


const app = express();

app.use(cors());

app.use(bodyParser.json());


// MongoDB connection

mongoose.connect('mongodb://localhost:27017/mean-app', {

  useNewUrlParser: true,

  useUnifiedTopology: true

}).then(() => console.log('Connected to MongoDB'))

  .catch(err => console.error(err));


// Basic route

app.get('/', (req, res) => {

  res.send('Hello from Express!');

});


const PORT = 3000;

app.listen(PORT, () => console.log(`Server running at http://localhost:${PORT}`));

➤ Run the Server:

bash

Copy

Edit

node server.js

✅ Final Check


Component Check Default Port

Node.js + Express node server.js http://localhost:3000

Angular App ng serve http://localhost:4200

MongoDB mongod mongodb://localhost:27017

๐ŸŽฏ What’s Next?

Connect Angular to Express via HTTP services


Build a full CRUD API using MongoDB


Add authentication (e.g., JWT)


Deploy your MEAN stack app


Would you like a tutorial on building a full CRUD app using this stack?

Learn Mean Stack Course

Read More

Setting Up Your First MEAN Stack Application

What is difference between MEAN stack developer and FULL stack developer?

Visit Our Quality Thought Training in Hyderabad

Get Directions 


Comments

Popular posts from this blog

Understanding Snowflake Editions: Standard, Enterprise, Business Critical

Installing Tosca: Step-by-Step Guide for Beginners

Why Data Science Course?