Getting Started with MEAN Stack

Javascript has become a hot topic of the day, thanks to the number of awesome frameworks available and more than that the awesome community of developers supporting this open source development. Javascript is no more just a front-end scripting language that it used to be. With arrival of Node.js, any front-end Javascript developer can now become a Fullstack developer.

Since you are reading this article, I’ll assume that you have at least some prior Javascript experience and you are thinking about utilising that experience for fullstack application development.

So, as you might already know, MEAN stack is a web development technology stack consisting of MongoDB, ExpressJS, AngularJS and NodeJS.

This article will mainly focus on –

  1. Installation of NodeJS
  2. Installation of MongoDB
  3. Setup Node environment with some important global Node packages
  4. To see how all these fit together to make an awesome application stack.
  • Install NodeJS

NodeJS is a JavaScript runtime built on Chrome’s V8 JavaScript engine. NodeJS uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. NodeJS’ package ecosystem, npm, is the largest ecosystem of open source libraries in the world.

NodeJS installation in a pretty straightforward process. You can download the windows installer from https://nodejs.org/en/. Once downloaded open the .msi file you downloaded.

NodeJS Setup

Click ‘Next’, accept the license agreements and proceed with the setup. Once the installation finished, open command prompt as type-

  • `node -v`
  • `npm -v`

This should show you something like this-

node-version-check

In case you are wondering what npm is, npm(Node Package Manager) is a package manager for Node. Find out more about npm here.

If you did not get the outputs for `node -v` and `npm -v` as shown above, please make sure the node installation directory is added to your Path variables. It should be added be default with installation.

So that concluded NodeJS installation.

  • Install MongoDB

MongoDB is a free and open-source cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with schemas.

Installation of MongoDB is also a straightforward process. Download the setup from https://www.mongodb.com.

Please Note:  At the time of this writing, MongoDB 3.x faces some compatibility issues with Windows 7. So, if you are using Windows 7, you should probably go for MongoDB 2.x

Once you have downloaded the setup file, open the file and proceed with the setup. Nothing too fancy there. Once you finish the installation, You need to create a directory which will be used by MongoDB for storing all the data. By default MongoDB uses C:\data\db. So create this directory.

To make sure that the MongoDB installation was successful, open command prompt and type `<MongoDB DIR>\bin\mongod.exe`

mongod1

You should see a message saying ‘waiting for connection on port 27017’, which means, you’ve started the MongoDB. To connect to this MongoDB server, keep this command prompt window as it is and open a new command prompt window and type  `<MongoDB DIR>\bin\mongo.exe`

mongo1

So, we are done with the MongoDB setup. If you don’t want to type the whole MongDB Installation directory path every time you want to start MongoDB, you can add the Mongo DB installation directory to your path variables.

As I said above, MongoDB uses C:\data\db as default directory to store all the data. But if you want to use any other directory, You can specify the directory path while starting MongoDB server – `<MongoDB DIR>\bin\mongod.exe –dbpath=D:\mongo\data\db`

If you are not comfortable with the command line mongo tool, you can also use third-party GUI tools like Robo Mongo or Mongo Express.

  • Setup Node environment with some important global Node packages
  1. Install bower
  2. Install Express JS

At this point, you should already have `npm` installed and ready to use. Fire up command prompt and run following commands to install bower and Express JS framework.

npm install -g bower
npm install -g express

That’s it guys. You have all you need to get rolling with MEAN stack. Visit again for a post on creating a basic MEAN stack application.

 

Leave a comment

Your email address will not be published. Required fields are marked *