Setting up MeanJS from scratch on Linux Ubuntu 14.04.1

This is a walk-through on installing MeanJS on Ubuntu 14.04.1. t took me a long time to do it, so I’m just writing it all down here so as to speed it up for someone else who might want to do the same. Please feel free to comment, for corrections, suggestions or anything of the sort. Keep in mind that this is being written in Jan’15, and some methods of installation might change as newer versions are released.

So, to have MeanJS installed on your system, you need to do the following.
1. Have MongoDB installed
2. Have Python installed
3. Have Node.js installed
4. Have git installed
5. Have Ruby

Installing MongoDB:

Run the following in terminal:

sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv 7F0CEB10

echo ‘deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen’ | sudo tee /etc/apt/sources.list.d/mongodb.list

sudo apt-get update

sudo apt-get install -y mongodb-org

This installs the latest release of MongoDB. Refer their home page for more details.

Testing MongoDB:

In the terminal, type mongod. This starts the database. In another terminal, type in mongo which establishes a connection with the database. This is the interface to interact with the database.

Python:

Ubuntu comes with python pre-installed, so theres nothing to worry about there. If you still want to install the latest version just to be sure(not required though) you can go ahead and check out this link.

Installing Node.js:

Okay, so the first thing you need to know is that you can’t install it by putting in sudo apt-get install node because this ‘node’ is a completely different package. Instead, this is what you need to do:

curl -sL https://deb.nodesource.com/setup | sudo bash –

sudo apt-get install nodejs

sudo apt-get install build-essential

More information on this process is available here. As far as I know, the Node Package Manager or npm is installed with node, so we don’t need to worry about that. npm is going to be a really important part of MeanJS

Checking your Node.js Installation:

You can check whether it was successfully installed by typing in the terminal nodejs -v. You can also check your npm by typing npm -v, this extension basically lets you know the version that you have installed.

Now an important thing to do here is link the command node with nodejs. To do this, type

ln /usr/bin/node /usr/bin/nodejs

The reason why we need to do this is that many packages that use NodeJS still use node instead of the newer nodejs command to run it.

You can also update npm (recommended) using:

sudo npm install npm -g

Installing git:

sudo apt-get install git

Installing MeanJS:

So, now that we have the groundwork set, we can go ahead and build MeanJS on it. At this point, its good to know that MEAN stands for MongoDB, Express, AngularJS and Node.js. We already have the first and last bits. AngularJS doesn’t need explicit installation, its already available like how you can use HTML and CSS on any computer. All you need is a text editor and browser. If you’re looking for a good editor, i suggest you install Sublime Text. Express comes with the MeanJS installation as a whole.

Getting MeanJS is not really an installation, but more like copying files, because thats basically what we are going to do: copy files fro a git repository:

git clone https://github.com/meanjs/mean.git meanjs

Doing this will add a new folder named ‘meanjs’ to whatever folder you are in when running this command in terminal. so now move into that folder:

cd meanjs

Theres a lot of stuff you still need before using this folder, hence do the following too:

sudo npm install

bower install

Another thing you need is ruby, so install that:

sudo apt-get install ruby-full

And that is pretty much it, I guess. now, to run this server, you need to give the command grunt in the terminal. This starts the default webpage at http://localhost:3000 you can go ahead and have a look at it.

Understanding MeanJS:

So, it took me even longer to figure out how to use MeanJS than it took to get the whole thing running. The file structure in the demo can be really overwhelming if you are new to web-dev. I spent hours searching for a good tutorial and finally found this on youtube:

MEAN Stack Intro: Build an end-to-end application

Its a great tutorial, really worth a watch if you are just starting out. I hope this articled helped you, if you have any suggestions or questions, please comment below, I would love to help you out. Happy deving!

Advertisements