Mean Tutorial 1

Pre-requisites:

1. Any IDE – Web Storm/Sublime/Brackets

2. Nodejs

3. Git – Command Prompt mode

4. MongoDB

Now I created a workspace in E:/I***/Z***

Open command prompt and drive to your workspace, here E:/I**/Z**

Now run npm init //this will create a package.json in your workspace

Give all necessary details like project name,version,author etc etc

then run npm install –save express jade

Now we have to create a git repository in your client directory..for that type git init

followed by gitignore file..In your client directory(E:/../..) just create a new file with name “.gitignore”

now you can test git by typing git status in cmd prompt which shows following

31-01-2015 23-45-38

 

node_modules – downloaded dependencies for node

idea – settings for our project

package.json and .gitignore – source control

Now we have to ignore .idea and node_modules directory because only source control files need to be monitored and maintain version control..hence write those two file names in gitignore file.

Type git status now..you can see the only 2 files listed in cmd as shown below..

01-02-2015 00-02-05

 

now add and commit as shown below..

01-02-2015 00-05-52

Lets install client dependencies using bower.

npm install bower –save -dev // only for my project

npm install bower -g // globally for all projects in my machine // this can be do later..so ignore for now

create a directory named server in your client directory.. // this is to store all your client side js files and node files

create a new directory named public to store all your assets..

before installing client side dependencies create ‘.bowerrc’ in your root directory(E:/../..)

inside that have the following code..

{

“directory”:”public/vendor”

}

now go to cmd and type bower init

01-02-2015 12-04-21

Now run bower install toastr –save

bower install angular angular-material angular-resource angular-route –save

Now go and check your bower.json file to check your recent dependencies installed.

create server.js file for node application. Create a file in your root directory(E:/../..)

 

Introduction to MEAN

Folks,

Why MEAN?

Client -> Server -> DB (all written by native js code)

angularjs -> nodejs -> MongoDB

31-01-2015 23-12-12

MongoDB stores BSON format which means Binary of json data. With all these three any developers can develop a complete application using javascript alone. I am afraid to say, but the truth is javascript is creating revolution in web applications now 🙂

The best guide to start up with mean framework is http://learn.mean.io/ only.

The best part in that site is step by step tutorial..

Install Mongodb,nodejs,git and grunt first..followed by $ npm install -g grunt-cli

$ npm install -g mean-cli

$ mean init <myApp> // this will ask you to create a appname followed by grunt/gulp customization

$ cd <myApp> && npm install

Then run “grunt” cmd in cmd prompt…

16-01-2015 19-38-51

Now enter localhost:3000 in your chrome browser…

16-01-2015 19-43-08

reason why i had this post it..while you follow step by step in installing mean..they mentioned to install mean..but they didn’t specified the errors you get while you start with those instructions alone..

After installing mongodb..first and foremost thing is to set path in environment variables path..

first check path in cmd by typing path…

now you can do it temporarily by having “set path=%path%;C:\Program Files\MongoDB 2.6 Standard\bin” or

go to controlpanel->system->advanced system variables->environment variables->path->edit and add bin folder and click on save..

this will solve to clear this error(could not connect to mongodb. please ensure mongodb is running)

the next error you get when you type mongod in cmd prompt is..

error dbpath (/data/db/) does not exist.

for this..just create a folder like “C:\mongodb\data\db” and type this cmd in prompt like

 mongod --dbpath c:\mongodb\data\db


I am interested to work with angular-material framework..hence i executed the necessary cmds..

npm install -g bower

bower install –save angular-material angular-socket-io