Install MEAN.JS stack in Ubuntu 14.04 LTS
MEAN.JS stack consists of the following:
- MongoDB – NoSQL database.
- Express – NodeJS server-side application web framework.
- AngularJS – Client-side web application framework.
In this tutorial, we will be discussing how to install MEAN.JS stack in Ubuntu. This guide was tested in Ubuntu 14.04 LTS server.
MongoDB is available in default repositories. However, it might be old version. So, we add MongoDB official repository to get latest version of MongoDB.
Import MongoDB repository GPG key using command:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
Add MongoDB repository using command:
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
Update the software repository lists:
sudo apt-get update
Finally install MongoDB with required prerequisites in Ubuntu 14.04 LTS with the following command:
sudo apt-get install mongodb-org build-essential git libssl-dev openssl pkg-config
You can check whether MongoDB service is running or not using command:
sudo service mongod status
mongod start/running, process 8698
Now, let us install Node.js,
Node.js is available in default repositories. However, in-order to get latest version, we need to add Node.js official repository.
To add Node.js repository, run:
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
Then, install Node.js using command:
sudo apt-get install nodejs
The above command will install nodejs and npm. You don’t need to install npm separately. Npm or Node.js package manager is used to install additional packages required for installing MEAN stack.
To check the Node.js version run the following command:
After installing, MongoDB, and Node.js, we need to install the other required components such as Bower, Frunt, and Gulp for MEAN.js stack.
Install Bower package manager
Bower is a package manager used by MEAN.JS stack to manage front-end packages.
To install Bower, run the following command:
sudo npm install -g bower
/usr/bin/bower -> /usr/lib/node_modules/bower/bin/bower /usr/lib `-- [email protected]
Install Grunt Task Runner
Grunt Task Runner is used to to automate the development process.
To install Grunt, run:
sudo npm install -g grunt-cli
/usr/bin/grunt -> /usr/lib/node_modules/grunt-cli/bin/grunt /usr/lib `-- [email protected] +-- [email protected] | `-- [email protected] | +-- [email protected] | | `-- [email protected] | +-- [email protected] | +-- [email protected] | | `-- [email protected] | | +-- [email protected] | | `-- [email protected] | +-- [email protected] | `-- [email protected] +-- [email protected] | `-- [email protected] `-- [email protected]
Install Gulp Task Runner (Optional)
This is optional. You can use Gulp instead of Grunt. To install Gulp Task Runner, run the following command:
sudo npm install -g gulp
We have installed all required prerequisites. Now, let us deploy MEAN.JS stack.
Download and Install MEAN.JS Stack
Git clone the MEAN.JS repository with command:
git clone https://github.com/meanjs/mean.git meanjs
Cloning into 'meanjs'... remote: Counting objects: 8596, done. remote: Compressing objects: 100% (12/12), done. remote: Total 8596 (delta 3), reused 0 (delta 0), pack-reused 8584 Receiving objects: 100% (8596/8596), 2.62 MiB | 140.00 KiB/s, done. Resolving deltas: 100% (4322/4322), done. Checking connectivity... done.
The above command will clone the latest version of the MEAN.JS repository to a meanjs folder.
Go to the meanjs folder:
Run the following command to install the Node.js dependencies required for testing and running our application.
sudo npm install
This will take some time. Please be patient.
Once all dependencies are installed, run the following command to install all the front-end modules needed for the application.
sudo bower --allow-root --config.interactive=false install
MEAN.JS stack has been installed. We can now able to start a sample application using Grunt task runner. To do so, run the following command:
In case it didn’t work, use –force flag.
After a few seconds, you will see a message like below. This means MEAN.JS stack is working.
[...] [nodemon] starting `node --debug server.js` Debugger listening on port 5858 -- MEAN.JS - Development Environment Environment: development Server: http://0.0.0.0:3000 Database: mongodb://localhost/mean-dev App version: 0.5.0-beta MEAN.JS version: 0.5.0-beta [...]
To verify, open up the browser and navigate to http://localhost:3000 or http://IP-Address:3000/. You should see a screen something like below.
Congratulations! MEAN.JS stack is ready to start building web applications.
For further details, I recommend you to refer MEAN.JS stack official documentation.
Want to setup MEAN.JS stack in CentOS, RHEL, Scientific Linux, and Fedora? That’s easy! Check the following link for more details.
That’s all for now folks. Hope this tutorial will help you to setup MEAN.JS stack.
If you find this tutorial useful, please share it on your social networks and support OSTechNix.