In this article, I will discuss how to install and configure the MEAN stack on Ubuntu.
To follow this guide you should have the following –
- A system with a recent version of Ubuntu (I will use Ubuntu 20.04 LTS)
- Access to a user account with sudo privileges
How to install MEAN stack on Ubuntu
Follow the steps that are given below to install and configure the MEAN stack on the Ubuntu system.
Update package index on your system
Before installing MEAN make sure your system package repository is updated –
sudo apt update
First, import the GPG key and add the MongoDB repository by using –
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
sudo add-apt-repository 'deb [arch=amd64] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse'
Next, run the update command –
sudo apt update
Finally, use the given command to install the MongoDB on your system-
sudo apt install mongodb-org -y
Once it gets installed use the following command to start and enable MongoDB –
sudo systemctl start mongod
sudo systemctl enable mongod
You can follow a detailed article on how to install MongoDB in Ubuntu.
There are various ways to install NodeJS on Ubuntu. We will use NVM or Node Version Manager to install Node.js on Ubuntu. This allows you to install and maintain different versions of Node.js and associated packages.
First, install NVM by using the given command –
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
Restart your shell or use the following command to source the file –
You can check the available NodeJS versions by using –
nvm list-remote | more
We will install the latest LTS release of NodeJS –
nvm install node
Once installation is completed you can verify the installation by using –
Installing required tools for downloading MEAN stack
We need some packages i.e. Git, Yarn, Gulp, and Bower to be installed on our system these will be required in downloading and installing the MEAN stack.
Use the following command to install requisite packages-
sudo apt install git -y
sudo npm install -g yarn
sudo npm install -g gulp
sudo npm -g bower
After installing the above package you can now install the MEAN stack first clone it from GitHub by using –
git clone https://github.com/meanjs/mean.git
Next move to the mean directory –
Run the given command to install the required packages –
sudo npm install
Now start the development server by using –
Verify MEAN installation
Now everything has been set up and you started the MEAN development server. Open a browser and type the given URL to see the default MEAN page-
For example –
You have successfully set up the MEAN stack on your system. now if you have a query then write us in the comments below.