How to install MEAN Stack (MongoDB, Express.JS, Angular.JS, Node.JS) on Ubuntu 16.04

Introduction

MEAN.js is full javascript stack that contains MongoDB, Express JS, Angular JS, and Node JS. This javascript framework accelerates the web application development using Javascript as backend.

Using the MEAN stack you can rapidly build easily maintainable web applications based on Javascript.avascript.


MongoDB- is schemaless NoSQL database system, MongoDB saves data in binary JSON format which makes it easier to pass data between client and server.

Express JS -  is a lightweight framework used to build web applications in Node. It provides a number of features for building single and multi-page web applications.

Angular JS - is a Javascript framework developed by Google. it provides some awesome features like two-way data binding. It is a complete solution for rapid and awesome front-end development.

Node JS -  is server-side Javascript execution environment. It's a platform built on Google Chromes V8 Javascript runtime. It helps in building highly scalable and concurrent application rapidly.

MEAN Installation-
To Install MEAN stack, first, we need to install dependencies - To install prerequisites run below command.

Step 1- Dependencies Installation:
$ sudo apt-get install build-essential git fontconfig libpng-dev ruby ruby-dev
After finish above prerequisites installation, use below command to install sass.
$ sudo apt-get install sass
Once all the above dependencies get installed. let's proceed for MEAN stack installation.
Step 2- Install Mongo DB:
In order to install Mongo DB as the database server. First, add MongoDB official repository:
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
Run the command below to add repository data to the local system correct path
$ sudo echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.4.list
Once, repository added. Update package databased 
$ sudo apt-get update
After package database update, we can proceed MonogDB installation.
To install MongoDB run following command.
$ sudo apt-get install mongodb-org
To install a specific release of MongoDB use following command. For example, I would like to install MongoDB version 3.6.3
$ sudo apt-get install -y mongodb-org=3.6.3 mongodb-org-server=3.6.3 mongodb-org-shell=3.6.3 mongodb-org-mongos=3.6.3 mongodb-org-tools=3.6.3
After MongoDB installation, Start MongoDB service using below command.
$ sudo systemctl start mongod.service
Let's check MongoDB service status-
$ sudo systemctl status mongod.service
Enable MongoDB Service to start at system boot.
$ sudo systemctl enable mongod.service
Step 3- Install Node JS and NPM -
In order to install Node.JS and NPM we have to add the “NodeSource” repository, the following bash script will do this easily:
$ sudo curl -sL https://deb.nodesource.com/setup_8.x | -E bash -
Now, Install Node.JS and NPM 
$ sudo apt-get install nodejs
Check installed NodeJS version
$ sudo node -v
For NPM version
$ sudo npm -v 
Step 4- Install Yarn and Gulp -
yarn is package management tool for client-side programming and it depends on NodeJS and NPM
You can install Yarn with NPM command.
$ sudo npm install -g yarn
Gulp is a JavaScript task runner that can automate many tasks, you can install it with NPM command as well:
$ sudo npm install -g glup
For verifying that Bower and Gulp are installed successfully you can execute the following command:
$ sudo npm list -g --depth=0
You should see something like below:
/usr/lib
├── yarn@1.3.2
├── gulp@3.9.1
└── npm@5.3.0
Step 5 - Download and Install MEAN from Git.
Now we can download the latest version of MEAN which is “0.6.0” at the time of writing.
Execute the following command:

$ cd /opt
$ sudo git clone https://github.com/meanjs/mean.git
Switch to MEAN the main directory:
$ sudo cd mean
Now, Install mean with the following command.
$ sudo npm install
After the installation process is finished without errors you can execute the command below to install the front-end stuff:
$ sudo yarn install --allow-root
Step 6 - Start and test MEAN
Now, you can easily start MEAN stack Project with the following command.
$ sudo npm start

To run npm start command in the background run the following command. This command will help us to keep running npm server in the background.
$ sudo nohup npm start &
It should run without any errors and you can look up your MEAN stack default page through the following address:
http://IP_addresss:3000
You should see a page like below:

Congrats! you have successfully configured MEAN stack and run the sample application!



11 comments:

  1. IT's very informative blog and useful article thank you for sharing with us , keep posting such quality content.
    MEAN Stack Training
    MEAN Stack Online Training

    ReplyDelete
  2. Good information and the content is very useful .Thanks for sharing with us.

    Mean stack online training
    Mean stack training in hyderabad

    ReplyDelete

Note: Only a member of this blog may post a comment.

How to Setup Chef Workstation, Hosted Chef Server and Configure Node using Chef cookbook

Chef:   Chef is a powerful tool for automation that transforms infrastructure into code. Whether you're operating in the cloud or on-pre...