Here I am going to show you that how we can create a Powerful MVC web-application using Node.js. I am going to use locomotive framework to create the web-application. Before starting I would like to give you brief introduction about the locomotive : “Locomotive is a web framework for Node.js. Locomotive supports MVC patterns, RESTful routes, and convention over configuration, while integrating seamlessly with any database and template engine. Locomotive builds on Express, preserving the power and simplicity you’ve come to expect from Node.” For more info you can visit locomotive official site.
Now time to create the web-application, so lets start the building the application. For doing the same first we have to install the locomotive.
We can install the locomotive using node package manager using command
npm install locomotive
but we have to install locomotive globally so we can access locomotive from any where from our system so we need to execute command
npm install locomotive -g
. Once installation is done , we are ready to create application. Below are the step we need to follow in order to create a nodejs web application :
- Open the terminal and and go to your work space directory and execute
lcm create node-web-app
It will create the structure of the nodejs web application (node-web-app is the application name). You can see the output like
- If you are able to see the same output on your terminal then you have successfully created the application named “node-web-app”
- Go to your node-web-app directory and execute “npm install” by executing this command it will resolve all dependency of the application which is mentioned by default in the application and then run the application using command lcm server. It will start your application on port 3333. You can access your application from browser using localhost:3333
Now we are able to create and run nodejs web application using locomotive. In my next blog I will explain architecture of the application.