How to Install Node.js, Angular, and MongoDB — Complete MEAN Stack Setup Guide (2025)
The MEAN Stack — consisting of MongoDB, Express.js, Angular, and Node.js — is one of the most popular full-stack JavaScript development stacks in 2025.
It allows developers to use JavaScript for both frontend and backend development, making web app creation faster, simpler, more efficient, and developers friendly.
In this step-by-step guide, you’ll learn how to install Node.js, Angular, and MongoDB on your system and set up a fully functional MEAN Stack environment from scratch.
What Is MEAN Stack?
The MEAN Stack is a collection of four powerful technologies:
Together, they enable developers to build dynamic, scalable, and modern web applications — all in JavaScript.
Prerequisites
Before we begin, make sure you have:
A system running Windows, macOS, or Linux
Basic understanding of TypeScript (JavaScript)
Stable internet connection
Administrator or sudo access
Step 1: Install Node.js and npm
What Is Node.js?
Node.js is a JavaScript runtime built on Chrome’s V8 engine that lets you run JavaScript outside of the browser.
It comes with npm (Node Package Manager), used to install libraries and frameworks.
Installation Steps
On Windows
Go to nodejs.org
Download the LTS (Long Term Support) version
Run the installer and follow the steps
Verify installation:
node -v
npm -v
On Ubuntu / Linux
sudo apt update
sudo apt install nodejs npm -y
node -v
npm -v
On macOS
Using Homebrew:
brew install node
Once done, Node.js and npm will be installed globally.
Step 2: Install Angular CLI
What Is Angular CLI?
The Angular CLI (Command Line Interface) helps you create, develop, and manage Angular projects easily on any IDE or Command Line User interface .
Install Angular CLI Globally
npm install -g @angular/cli
ng version
Create a New Angular App
ng new mean-frontend
cd mean-frontend
ng serve
Now open your browser at:
http://localhost:4200
You’ll see your Angular app running successfully.
Step 3: Install MongoDB
What Is MongoDB?
MongoDB is a NoSQL document-oriented database that stores data in JSON-like structures.
It’s flexible, scalable, and ideal for handling large datasets.
Installation Steps
On Windows
Download and install MongoDB Community Server
Add MongoDB to your system PATH
Start MongoDB
net start MongoDB
On Ubuntu / Linux
sudo apt update
sudo apt install -y mongodb
sudo systemctl start mongodb
sudo systemctl enable mongodb
On macOS
brew tap mongodb/brew
brew install mongodb-community
brew services start mongodb-community
Check if MongoDB is running:
mongo
If you see the MongoDB shell prompt, your installation is successful.
Step 4: Connect Node.js with MongoDB
Now that you have MongoDB and Node.js installed, let’s connect them.
Initialize a Node Project
mkdir mean-backend
cd mean-backend
npm init -y
npm install express mongoose cors
Create a Simple Server
Create a file named server.js:
const express = require('express');
const mongoose = require('mongoose');
const cors = require('cors');
const app = express();
app.use(cors());
app.use(express.json());
mongoose.connect('mongodb://localhost:27017/meanstackdb')
.then(() => console.log('Connected to MongoDB'))
.catch(err => console.error(err));
app.get('/', (req, res) => {
res.send('MEAN Stack Backend is Running!');
});
app.listen(3000, () => console.log('Server started on port 3000'));
Run the server:
node server.js
Visit:
http://localhost:3000
You’ll see:
“MEAN Stack Backend is Running!”
Step 5: Verify MEAN Stack Connection
At this point:
- MongoDB stores your data
- Node.js and Express.js handle the backend logic
- Angular serves the frontend
You now have a fully working MEAN Stack setup on your local system.
Optional: Use MongoDB Atlas (Cloud)
If you prefer not to install MongoDB locally, use MongoDB Atlas — the official cloud service.
Go to MongoDB Atlas
Create a free account and cluster
Connect your app using this connection string:mongodb+srv://<username>:<password>@cluster0.mongodb.net/
mongoose.connect('your-atlas-connection-string')
Best Practices for MEAN Stack Setup
Use LTS versions of Node.js for stability
Organize backend into folders (routes, models, controllers)
Use .env for environment variables
Secure MongoDB with authentication
Keep dependencies updated regularly
Use Postman or Thunder Client to test APIs
Conclusion
Setting up the MEAN Stack is the first big step toward becoming a Full-Stack JavaScript Developer.
With Node.js, Angular, and MongoDB installed, you can now start building powerful, data-driven web applications using a single language — JavaScript.
This setup provides you with a robust environment to develop, test, and deploy modern full-stack projects efficiently.
No comments:
Post a Comment