Why Node.Js? install express,Mongo DB and Jade

Hey Guys,

In this tutorial I want to show you how we can convert Node.Js to a web-server or even more. To do this conversion you need to install express, and also you need to do a few things:

run you command prompt and follow the steps:

  1. Create a directory for Node.js project

E:/mkdir node

2. now you need to install express, please use this command:

E:\node>npm install -g express-generator

3. Create a simple project in your node directly that you created in step 1

E:\node>express nodetest1

4. if you go to that folder you can see a few files and folders are added, this is simple project which is created for us and we want o change some of the configurations. if you open the node folder you can see the package.json, this json file contains list of dependency packages that are needed for this project. if you open the file in any text editor you can see something like :

{
“name”: “nodetest1”,
“version”: “0.0.0”,
“private”: true,
“scripts”: {
“start”: “node ./bin/www”
},
“dependencies”: {
“body-parser”: “~1.12.4”,
“cookie-parser”: “~1.3.5”,
“debug”: “~2.2.0”,
“express”: “~4.12.4”,
“jade”: “~1.9.2”,
“morgan”: “~1.5.3”,
“serve-favicon”: “~2.2.1”
}
}

we only need to add a few items to the dependencies, as I want to show you how to use mongoDB in node js, so we need to add mongoDB dependency to this file. Please change the dependencies section like this:

“dependencies”: {
“body-parser”: “~1.12.4”,
“cookie-parser”: “~1.3.5”,
“debug”: “~2.2.0”,
“express”: “~4.12.4”,
“jade”: “~1.9.2”,
“morgan”: “~1.5.3”,
“serve-favicon”: “~2.2.1”,
“mongodb”: “~2.0.33”,
“monk”: “~1.0.1”
}

5. Next step is to install all dependencies that are mentioned in the package.json. run the command prompt and execute the below command:

E:\node\nodetest1>npm install

6.Once you install everything, you need to create a data directity in node folder, the reason that we need to create data folder is that we want to user mongoDB and we already installed dependency for mongoDB, so without data folder you will face with error 🙂 , so easily run this command in command prompt:

E:\node\nodetest1>mkdir data

7. Now everything is ready to run the Node.js, to run Node.js  you can execute the below command:

 E:\node\nodetest1>npm start

8: To see the result of what have done in this tutorial type this address in browser:

http://localhost:3000

Maybe you are still a bit confused about node.js, but do not be please, it is very normal specially for those programmers that are not familiar with these kind of coding and environments. we just started and you need go through the whole training to understand what exactly is happening. 🙂

Bye bye

Advertisement

How can ask Visual Studio to track active and open file?

One of the annoying default setting in visual studio is that solution explores does not track an active and open file. To solve this problem just follow the below path :

Tools – Options – Projects and Solutions – Track Active Item in Solution Explorer

Good Luck 🙂

Finding the user’s current region using RegionInfo in .NET C#

That’s really Cool !!

Exercises in .NET with Andras Nemes

The CultureInfo object helps a lot in finding information about the user’s current culture. However, on occasion it may not be enough and you need to find out more about that user’s regional characteristics. You can easily retrieve a RegionInfo object from CultureInfo which will hold information about a particular country or region.

You can find the current region in two ways from CultureInfo:

My computer is set to use Swedish-Sweden as the specific culture so I get the following values from top to bottom:

  • Sweden
  • kr
  • Swedish krona
  • Svensk krona

If I change the current culture to my home country, i.e. Hungary…

…then the values are of course adjusted accordingly:

  • Hungary
  • Ft
  • Hungarian Forint
  • forint

Read all posts related to Globalisation in .NET here.

View original post