Introduction to MEAN Stack
This article will take you through the installation of MEAN stack on your Linux virtual server based on CentOS 7.
The first step is setting up your Machine for the installation. Before any installation begins, ensure that your machine has the following
- Git. Confirm that you have GIT installed in your system. To confirm the installation run the command
# git --versionon the terminal.
- Ensure that dependencies are installed. Run the following commands
# gem install sass
# yum install gcc-c++ make git fontconfig bzip2 libpng-devel ruby ruby-devel
Special Note: Consult with Hostadvice's Best MongoDB hosting page to find the top MongoDB hosting services. .
# nano /etc/yum.repos.d/mongodb.repo
This will open a new text file. Paste the following code and save it, then exit the editor.
[mongodb-org-3.6] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.6/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc
Install MongoDB by running the following command:
# yum install mongodb-org
Once the installation is complete, start and enable the database service with the following commands:
# systemctl start mongod #systemctl enable mongod
To verify that the service is running, run the following command
# systemctl status mongod
Installing Node JS.
Special Note: Consult with Hostadvice's Best Node.js hosting page to find the top Node.js hosting services.
# curl -sL https://rpm.nodesource.com/setup_9.x | bash
The next step is installing Node JS and NPM
# yum install -y nodejs
Check whether the installation was successful by running
# npm version # node version
Installing Bower and Gulp
These are components of the mean stack. Bower is a package manager for the front-end apps, while gulp automates tasks. The installation of both must be global so that they are available system-wide.
Run the following command to install bower and gulp respectively.
# npm install -g bower # npm install -g gulp
Verify the installation was successful by running these commands
# npm list -g --depth=0
This should yield the following
Now that are the prerequisite installations are done, it is time to install Mean boilerplate. This is done by cloning it from github.
# git clone https://github.com/meanjs/mean.git
With the boilerplate on your home directory, you need to install the project references by accessing the directory. Run;
# cd mean
To install mean run:
# npm install
This might take a few minutes but once install front-end resources by typing;
# bower install --allow-root
Running the First Application
To start MEAN stack project, use the commands below:
# npm start
At first you might experience the following error
[12:56:49] 'lint' errored after 702 ms
[12:56:49] Error in plugin 'run-sequence'
An error occurred in task 'sass'
Correct the errors by running these commands:
# rm -rf node_modules # npm cache clean # npm install # npm start
To access the MEAN application, type the link below on your browser:
It should yield a page like the one below.
You can start building and deploying your applications.
Check out the top 3 Dedicated server hosting services: