The MEAN stack pt.4: getting MEAN

Now, finally, we are ready to get MEAN!

Get Grunt!

npm install -g grunt-cli

Get Git!

sudo apt-get install -y git


git clone myproject
#or if you need replica set support:
#git clone myproject
cd myproject
npm install

Configure it!

In config/env/development.json at the top is your DB connection string.

If you have locked down your mongo server or are using replica sets, you will need to make changes here.

The format of the connection string and other options can be found here:


You may want to create a database user for your app.

> use admin
switched to db admin

> db.auth("<admin_username>","<admin_password>")

my_replica_set:PRIMARY> use my_app_db
switched to my_app_db

my_replica_set:PRIMARY> db.addUser( { user: "my_app_user",
                                pwd: "my_app_password",
                              roles: [ "readWrite" ] } )

{ the user object }







You should now be able to connect to your app at port 3000! If you set up a replica set, and 3 node servers, they should all be sharing data through mongo. Try making a user on the first machine, logging in to the second and creating an article, and then looking at the articles you made on the third. They should all be in sync, and you should be able to just shut down the server currently acting as the primary database server without any problems.

It’s Fantastic!




Leave a Reply