\

Part 2-MEAN Application Setup Node Module Packages

Mean Application Setup Node Module Packages

In this tutorial, we will do Mean Application Setup Node Module Packages i.e the node package modules (npm), also we will create the directory structure for our application.


Check out the Demo on MEAN Stack Application-BookStore .





Download Bookstore MEAN Application.






Set Up Application

Let’s start with setting up npm, creating a project with the command:


npm init

After filling up the details related to the project the next step we will be doing is installing the required node module packages.
We will be installing the 3 node module by the following command:


npm install express --save
npm install body-parser --save
npm install mongoose --save

Therefore it will generate a package.JSON file automatically with the modules which we have installed.

package.json

{
  "name": "bookstore",
  "version": "0.0.1",
  "description": "bookstore application",
  "main": "app.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "dependencies":{
  	"express":"*",
  	"body-parser":"*",
  	"mongoose":"*"
  },
  "author": "Geeks Trick",
  "license": "ISC"
}

As you can see in above code, the three dependencies which we have been install and it automatically saves the details in it. So whenever the project is shifted or any reason we just need to do npm install

Directory Structure

After installing all the node module dependencies, we will set up the flow of our application which will contain two stages. one will be backend part and another one will be for UI part and will folder be named as ‘client’.

Let’s start building the app structure, as we install our dependencies it has automatically created the folder for node packages named as ‘node_modules’.

Directory Structure

|  ////////// SERVER SIDE ////////// 
|---Package.json
|
|---node_modules(folder)
|                 |---*files // Dependencies Files
|
|---app.js // main file
|
|---models(folder)
|                 |---book.js // For API
|=======================================================
|  ////////// CLIENT SIDE ////////// 
|
|---client(folder)
|       |
|       |---index.html // main file
|       |---app.js // angular app
|       |
|       |---views(folder)
|       |          |---add_book.html
|       |          |---book_details.html
|       |          |---books.html    // will be home page
|       |          |---edit_book.html
|       |
|       |---controller(folder)
|       |          |---books.js
|       |
|       |---styles(folder)
|       |          |---style.css
|       |
|       |---bower_components(folder)
|       |                   |---*files /* Files of Angular, UI-Router 
                                              Bootstrap, Jquery  */

We will be following this structure, as it is a simple MEAN Stack app we will create a simple structure of our application.

For highly functioning application you can use Node Express App Structure

Directory Structure
Mean Application Setup Node Module Packages

MEAN Stack Series – Links

About This Author

Hi This Is Rehmaanali. Blogging Is Just A Hobby. Graduate In Bsc Computer Science

Post A Reply