Budget and time are the biggest constraints that people usually face while building an application. So, before starting any new project, we need to set up all the required tools and project structure which is time consuming. Practicing code reuse and using web application frameworks for this can greatly improve both productivity and time.
“Every website you visit is the product of a unique mixture of libraries, languages, and web frameworks.” — IBM
What is MEAN?
The authors of MEAN Stack define it as :
Components of MEAN
MEAN is an acronym for MongoDB, ExpressJS, AngularJS, NodeJS.
So, its components are :
M – MongoDB – Data Storage (NoSQL Database)
E – ExpressJS – Web Application framework (Backend framework)
A – AngularJS – Frontend framework
N – NodeJS – Web Server
- With NodeJS, we don’t need to deploy finished application to a stand-alone web server, instead, web server is included in the application itself and installed automatically with MEAN stack.
- With NoSQL database like MongoDB, no need to spend time writing complex SQL queries.
- The shift from LAMP to MEAN is the move from traditional server-side page generation to a client-side single page application orientation.
- Support for the MVC pattern.
- LAMP stack restricts OS to Linux but MEAN brings OS independence. Node.js runs as well on Windows and OS X as it does on Linux.
Before getting started with MEAN stack, we need to install various MEAN software packages.
- Install NodeJS
$ sudo apt-get update
$ sudo apt-get install nodejs
$ sudo apt-get install npm
- Install MongoDB
Visit the MongoDB home page, download the platform-specific installer, and accept
the defaults as you install MongoDB.
There are two ways to install and get going with MEAN stack:
- Clone the git repository:
$ git clone https://github.com/linnovate/mean.git
- Use the yeoman generator : Yeoman is a scaffolding tool. To use it, we first need to install Yeoman or Yo generator.
- Install Yeoman generator :
$ npm install -g yo
- Once yo-generator is installed , we need to install Mean generator as well:
$ npm install -g generator-meanjs
- Then, to install the new copy of application in your working directory, type the
$ yo meanjs
- Install Yeoman generator :
With yo-generator, one can easily create CRUD module by the following command:
$ yo meanjs:crud-module <module-name>
This command will create both the ExpressJS and AngularJS CRUD modules along with the test cases.
Once you have done setup for MEAN application, you can check its status whether everything has been installed or not by using the following command:
$ mean status
Also make sure you do run the following command to make sure all the dependencies are installed before you run the Node server:
a.) $ npm install – To install all the server side node modules
b.) $ bower install – To install all the client side libraries
Mean Stack Directory Structure
App – contains all the server side backend code
Public – contains all the client side code
So, all the ExpressJS code i.e the controllers, routes, views is defined under app directory, whereas the AngularJS related code is contained under public directory.
I hope I was able to explain everything which is needed for the setup. If you still face any issues, please drop your comments. I would be happy to help. 🙂
Thank you for reading.