MEAN (MongoDB, Express, Angular, Node) Stack : Kick Start First Project Using Generator

7:48 PM

Hello everyone, I am going to share my experience in settting up MEAN stack project for the first time.

So firstly, before we go further, what is MEAN stack ? MEAN stands for Mongo DB, Express, Angular, and Node. It is combination of modern and light technologies. Mongo DB as NoSQL database provider, Express JS as a Node JS web application framework, Angular JS as HTML and UI framework and Node JS, a lightweight and efficient JavaScript runtime, as the foundation of our web application.


Let's start installing MEAN stack framework.

I am going to use framework called Generator Angular Fullstack.
What is that ? Generator Angular Fullstack is,

 Yeoman generator for creating MEAN stack applications, using MongoDB, Express, AngularJS, and Node - lets you quickly set up a project following best practices.

Let's do M stuff from MEAN, which is installing Mongo DB.


Download MongoDB from this source. Choose your platform whether Windows, Linux, or OSX.

Do the installation,
Run your MongoDB
Create the default /data/db directory, by typing below command in your terminal or command prompt,

mkdir -p /data/db
Run without specifying paths,

If your system PATH variable includes the location of the mongod binary and if you use the default data directory (i.e., /data/db), simply enter mongod at the system prompt:


mongod
Specify the path of the data directory,

If you do not use the default data directory (i.e., /data/db), specify the path to the data directory using the --dbpath option:


mongod --dbpath 
Mongo DB is now running, and you can start making a connection

Next, continue installing Node JS.
Download the latest Node JS in this source.
Do the installation.
After installation is finished, check if the Node JS already installed by typing below command,
node -v
The output will be the version of Node JS for example v5.2.0.
Now, we begin downloading tools needed by Generator Angular Fullstack and Generator Angular Fullstack it self.
Installing yeoman, bowergrunt-cligulp-cliGenerator Angular Fullstack by typing the command below
npm install -g yo grunt-cli gulp-cli bower generator-angular-fullstack
-g flag on above command indicated that we want installed it globally.
After installation has completed, we can start using Generator Angular Fullstack.
We want to make a directory for our project so let's make a new directory, and cd into it :

mkdir my-new-project && cd $_
Run yo angular-fullstack, optionally passing an app name :
yo angular-fullstack [app-name]
Run grunt for building, grunt serve for preview, and grunt serve:dist for a preview of the built app.
Done, we are done installing Generator Angular Fullstack.
Now, before we run our project. Let's see the project structure below,


├── client
│   ├── app                 - All of our app specific components go in here
│   ├── assets              - Custom assets: fonts, images, etc…
│   ├── components          - Our reusable components, non-specific to to our app
│
├── e2e                     - Our protractor end to end tests
│
└── server
    ├── api                 - Our apps server api
    ├── auth                - For handling authentication with different auth strategies
    ├── components          - Our reusable or app-wide components
    ├── config              - Where we do the bulk of our apps configuration
    │   └── local.env.js    - Keep our environment variables out of source control
    │   └── environment     - Configuration specific to the node environment
    └── views               - Server rendered views
An example client component in client/app
main
├── main.js                 - Routes
├── main.controller.js      - Controller for our main route
├── main.controller.spec.js - Test
├── main.html               - View
└── main.less               - Styles
An example server component in server/api
thing
├── index.js                - Routes
├── thing.controller.js     - Controller for our `thing` endpoint
├── thing.model.js          - Database model
├── thing.socket.js         - Register socket events
└── thing.spec.js           - Test
Now, open server/config/environment/development.js in your favorite text editor.

'use strict';

// Development specific configuration
// ==================================
module.exports = {

  // MongoDB connection options
  mongo: {
    uri: 'mongodb://localhost/alphafullstack-dev'
  },

  // Seed database on startup
  seedDB: true

};
Look at mongo uri, it refers to our database in our currently running mongo. Don't worry I just want to let you know, you don't need to create the database with name of that. Once you run this project, it will automatically create a database with name of that.
Now, look at server/config/environment/index.js.
// Server port
port: process.env.PORT || 9000,
by default if we don't specify NODE_ENV to production, our app will use port 9000. So, let's try running our app by typing below command
grunt serve
and here it is what we got, our project is running.

You Might Also Like

57 comments

  1. I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.
    Mean Stack Online Training

    ReplyDelete



  2. Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.

    Mean Stack Training in Bangalore

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. very useful blog to learner so happy to be part in this blog. Thank you
    MEAN Stack Training
    MEAN Stack Online Training

    ReplyDelete
  5. Heartful thanks for the topic you have chosen for blogging.Great to come across such an effictive contents.Good project.
    honor service center near me
    honor service
    redmi mobile service centre in chennai
    redmi note service center in chennai

    ReplyDelete
  6. Everything is fine, am happy about your blog. Thanks admin for sharing the unique content, you have done a great job I appreciate your effort and I hope you will get more positive comments from the web users.
    Mean Stack Development Company In India
    Mean Stack Development Company In Chennai

    ReplyDelete
  7. Good content regarding Mean stack. Very helpful to kick-starters
    Mean Stack Online Training

    ReplyDelete
  8. The field of software development is vast and varied. A trying student, in the field of software development, must chose carefully what type of software he ought to specialize in. One of the areas of specialization, where great career opportunities exist is in MEAN Stack.
    For More Info: MEAN Stack Institute in Gurgaon

    ReplyDelete
  9. I think this is an informative and knowledgeable post. I want to thank you for your efforts to write this article.
    Node JS Online training
    Node JS training in Hyderabad

    ReplyDelete
  10. Excellent information and it is very helpful for those who wants to learn mean-stack.

    Mean stack online training
    Mean stack training in hyderabad

    ReplyDelete
  11. The Full Stack Developer training program begins with Node.js and Express.js, which provide a strong foundation to understand and construct web applications with the help of JavaScript.
    For More Info: MEAN Stack Course in Gurgaon

    ReplyDelete
  12. Thank you for providing this informative post. looking forward to read more.
    Web Design and Development Company

    ReplyDelete
  13. It is really a nice and useful piece of info. I'm glad that you just shared this helpful information with us. Please stay us informed like this. Thanks for sharing.
    amazon web services aws training in chennai

    microsoft azure training in chennai

    workday training in chennai

    android-training-in chennai

    ios training in chennai

    ReplyDelete
  14. First You got a great blog .I will be interested in more similar topics. i see you got really very useful topics, i will be always checking your blog thank
    MongoDB Training in Bangalore

    ReplyDelete
  15. Thanks for sharing amazing information.Gain the knowledge and hands-on experience

    Mongodb Training in Bangalore

    ReplyDelete
  16. Great Content. It will useful for knowledge seekers. Keep sharing your knowledge through this kind of article.
    Mean stack Classes in Chennai
    React JS Training Institute in Chennai

    ReplyDelete
  17. This post is more informative. Thanks for sharing this valuable information.
    Management And Leadership Training
    Managing Skills

    ReplyDelete
  18. This is really an awesome article. Thank you for sharing this.It is worth reading for everyone.
    Hire Angular Developer in India

    ReplyDelete
  19. Glad to find this. Your site very helpful and this post gives lots of information. Do share more updates.
    Application Areas Of Artificial Intelligence
    Applications Of Artificial Intelligence In Robotics

    ReplyDelete


  20. Nice to see this BLOG..keep updating More infromation Digital Lync offers one of the best Full Stack training in Hyderabad with a comprehensive course curriculum with Continuous Integration, Delivery, and Testing. Elevate your practical knowledge with quizzes, assignments, Competitions, and Hackathons to give a boost to your confidence with our hands-on Full Stack Training.
    DevOps Training Institute
    Python Training Institute
    AWS Training Institute
    Online Full Stack Developer Course Hyderabad
    Python Course Hyderabad
    Online AWS Training Course Hyderabad
    devops training in hyderabad
    angular training in hyderabad

    ReplyDelete
  21. Nice Blog , This is what I exactly Looking for , Keep sharing more blog .
    Dedicated AngularJS 2 developers

    ReplyDelete
  22. Great Post! Thanks for sharing. Keep sharing such information.

    Full Stack Training in Noida

    If you have any question related to course then you can call our expert directly on 70-70-90-50-90.

    ReplyDelete
  23. MEAN Stack Training in Delhi
    https://bumppy.com/tm/read-blog/46552_want-a-career-in-mean-stack-development-make-this-your-secret-weapon.html
    APTRON known among the main ten MEAN Stack Training Institute in Delhi, has preparing programs for fledglings, specialists and experts. Whether you are an undergrad, IT expert or undertaking supervisor; the amazing MEAN Stack Training in Delhi offers the best preparation offices, senior MEAN Stack coaches, and adaptability plans for all modules. Likewise, the great MEAN Stack Training in Delhi is requesting an expense for understudies.

    ReplyDelete
  24. MEAN Stack course in Noida
    https://aptronsolutions.home.blog/2022/08/04/mean-stack-institute-in-noida-mean-stack-training-in-noida/

    ReplyDelete
  25. Thanks for sharing such a great information.. It is really helpful for me. I am always searching for quality content to read and finally I found it in your post. The details about the Mean Stack project using the tool are excellent. Keep it up!

    ReplyDelete
  26. Hey Author This is a really very good article about Mean Stack . I am also a student Best Mean Stack Course In Kolkata. an Mean stack is an excellent career to choose. I appreciate you sharing this amazing article with us . this article was very helpful to me and also who wants to built career in this field .

    ReplyDelete
  27. Hey Author This is a really good article about MERN Stack .I have just started to learn Best MERN Stack Web Development Course In Kolkata . because in nowadays an MERN Stack developer is an excellent career . I found this information to be of great value. This article has increased my knowledge even more.
    Thank you ...

    ReplyDelete
  28. Thanks for sharing this informative article on MEAN (MONGO DB, EXPRESS, ANGULAR, NODE) STACK : KICK START FIRST PROJECT USING GENERATOR. If you want to hire mean stack developers for your project. Please visit us.

    ReplyDelete
  29. Thanks for the project. Find Nearest Metro Station on GoMetro

    ReplyDelete

Popular Posts

Like us on Facebook

Flickr Images