Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Install the MEAN Stack on Debian 12

MongoDB, Express, Angular and Node.js: install each part on Debian 12 and run a first app.

VPS and Cloud Servers2 min read20 screenshots

What MEAN is

MEAN is a set of JavaScript tools to build web apps:

  • MongoDB, the database.
  • Express.js, the web framework for Node.js.
  • Angular, the front-end framework.
  • Node.js, the runtime for the server.

Step 1: Update the system

sudo apt update
Updating the system

Step 2: Install Node.js and npm

Add the NodeSource repository (Node.js 18 is shown; use a current LTS such as 20 or 22 if you can):

curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
Adding the Node.js repository

Install Node.js (npm is included):

sudo apt install -y nodejs
Installing Node.js

Check the versions:

node -v
npm -v
The Node.js and npm versions

Step 3: Install MongoDB

Import the GPG key:

curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg --dearmor
Importing the MongoDB key

Create the source list. Debian 12 is not officially listed for MongoDB 7.0 on every build, so check the MongoDB documentation for your release. The example uses the Debian repository:

echo "deb [signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg] http://repo.mongodb.org/apt/debian bookworm/mongodb-org/7.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
Creating the MongoDB source list

Update and install:

sudo apt update
Updating the package index
sudo apt install mongodb-org
Installing MongoDB

Start and enable the service:

sudo systemctl start mongod
Starting MongoDB
sudo systemctl enable --now mongod
Enabling MongoDB

Check it:

sudo systemctl status mongod
The MongoDB status

Step 4: Install Express.js

Create a project folder:

mkdir myapp && cd myapp
Creating the project folder

Start a Node.js project:

npm init -y
Initializing the project

Install Express:

npm install express
Installing Express

Step 5: Set up Angular

Install the Angular CLI:

sudo npm install -g @angular/cli
Installing the Angular CLI

Create the Angular project:

ng new client
Creating the Angular project

Go into the folder:

cd client
Opening the client folder

Start the development server:

ng serve
Starting the Angular server

To reach it from outside the server, bind it to all addresses (and open the port in the firewall):

ng serve --host 0.0.0.0 --port 4200
Configuring the host and port

Step 6: Run the MEAN app

Open http://your_server_ip:4200. You see the Angular start page.

The MEAN stack is running

A real app has an Express server (server.js) with routes that read and write MongoDB (with the mongoose package), and an Angular front end that calls these routes with HttpClient.

Quick recap

  • Install Node.js, MongoDB, Express and the Angular CLI.
  • Start MongoDB with systemctl and Angular with ng serve.
  • Connect them with Express routes and Mongoose.