Hey guys! This is the fresh start of a brand new Express tutorials... Hope you have read my previous articles series es. If you are interested, this is the new one for you! What is Express ? Do you have any idea? Let me explain briefly.

What is Express?

I think you have already heard of the popular Run time Environment, Node JS. So Express is a Node JS framework that can be used simply to build web applications. 

It's fast and minimalist framework. Due to this tool, Coding using Node JS becomes very easy. There are lot of modules called node_modules available in Node JS that can be used with Express also.
For more details, visit the official site of Express framework.

I'm not going to explain you about its architecture. But I will show you the way to use this framework step by step..
Let's start!

What is our goal?
Usually NodeJS is used for server side configurations like creating a simple web server for us like Apache web server. It's the fundamental use of NodeJS. So we can do this using Express also with reduced steps compared to NodeJS.
prerequisites :
Node JS should be installed

Step 1 - Create a new project and initialize

Create a project with a name as you wish. I created as exmongo.  Then open project in VS Code or any text editor.
Navigate into the project with cmd.            cd exmongo
Node.js modules are a type of package that can be published to npm. To create a new module, we have to start by creating a package.json file. So we are going to create it.
Type this command on cmd now.
npm init
Then it will begin to create and you have to give some  details for this. After you entered this command, you will ask package name first. If you want to give a new one, type it. I recommend to keep it as default. Then hit enter..continue...
package name : exmongo
version : Keep as default and hit enter
description : Change if you want and hit enter
entry point : Type app.js and hit enter
test command , git repository, keywords : Keep as default and hit enter
author: Give your name - optional
license : Keep as default and hit enter


Finally give yes and terminate the process. Now there will be a new file called package.json with these details, in your project folder.

Step 2 - Install Express module into the project

We are going to use Express. So we use the below command to get the module. Open cmd and go into the project and type this.
npm install express --save

Output on cmd after installation :



Step 3 - Create the entry point

In our package.json file, we have give app.js as the entry point of the application. Therefore, now we are going to create a file called app.js in the project folder.
place this code in it.

console.log("Hello from Server");

Now we need to check the code is working or not. Open cmd and type this command.
node app.js
If there are no errors, cmd will output this..


We are ready to implement the server now!

Step 4 - Implement the server

Replace the code in app.js file with the following code.

// Load express module
const express = require('express');

// Initialize app
const app = express();

// Route for home
app.get('/', function (req, res) {
    res.send('hello world')
});

// Start server with port 3000
app.listen(3000, function(){
    console.log("Server started on localhost:3000");
});

Now we have completed the code for the server. Open cmd and type again  node app.js. Cmd will output this result..


Open the web browser and type localhost:3000 on address bar. Now you can see the root view of our project, since our server is up and running now!

We have fully implemented the web server now! This can be done without Express also..But few more steps.. Express is the easiest way I think.

So guys, this is the just beginning of Express tutorial. We will look deep into this framework in future articles. Practice makes you perfect!

Good Luck!



30 Comments

  1. Bahkan sekarang kamu juga dapat melakukan transaksi dana pada situs situs tersebut tanpa harus memiliki rekening bank. Hal ini tentunya sangat memudahkan banyak orang
    asikqq
    dewaqq
    sumoqq
    interqq
    pionpoker
    bandar ceme terbaik
    hobiqq
    paito warna
    bocoran sgp
    data hk

    ReplyDelete
  2. You are amazing. The representaion of this article is well structured and the steps are easy to follow.
    Node JS training in hyderabad

    ReplyDelete
  3. very nice blog thanks for the valuable information, i got an idea on how to Create a simple web server with Express
    Node JS Online training
    Node JS training in Hyderabad

    ReplyDelete
  4. Hey, thanks for the blog article .Really looking forward to read more. Cool.
    python training
    angular js training
    selenium trainings

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

    ReplyDelete
  6. thanks For sharing this top notch article.i exploit this newsletter to function my venture in college.it's far beneficial For me amazing paintings. Sony Vegas Pro 20

    ReplyDelete
  7. Malwarebytes Anti Malware Premium Serial Key that is my first duration i go to right here and i discovered consequently many enthralling stuff for your blog specifically it is aeration, thank you.

    ReplyDelete
  8. Thanks for sharing the nice information. Sapphire Solutions is the best
    NodeJS development company providing quality NodeJS development services to build secure, scalable, user-friendly and faster web applications.

    ReplyDelete
  9. I'd like you to know that this software is great and easy to use.
    Adobe Illustrator CC

    ReplyDelete
  10. Really its very useful information that you have shared and looks great post.. If you looking for company which provide best service for ExpressJS than connect with CodersNews. they listed Top 5 Industry-reviewed ExpressJS Web Development Agencies

    ReplyDelete
  11. Informative blog, Thanks for sharing. Looking for node js development services? Get the best node js web development services based on usa and India.

    ReplyDelete
  12. Excellent blog. Thank you for providing such useful information. Infowind tech is a Development company that provides the best Node.js development services
    in the IT industry. Hire Nodejs Developers if you are interested.

    ReplyDelete
  13. Informative blog, Thanks for sharing.
    hire nodejs developers to build high performing web aplications with ReactJS. Also Looking for best node js web development company? Choose 3Brain Technologies one of the best node ja company based on USA, India

    ReplyDelete
  14. Great article on setting up a web server with Express! For those interested in expanding their web development skills further, consider checking out the "Best Laravel Training Course in Surat" to enhance your expertise in another popular framework.

    https://decodex.io/laravel-training-course-in-surat

    ReplyDelete
  15. Great article! Node.js has certainly revolutionized the way we approach web development, especially with its non-blocking, event-driven architecture. For businesses looking to scale efficiently, Node.js development services are the go-to solution, offering high performance and real-time capabilities. Working with a professional Node.js development company ensures that your projects are built with expertise, making use of the latest technologies and best practices. Whether you're building a dynamic web application or handling complex backend systems, Node.js offers the versatility and speed necessary to meet modern demands. Highly recommend looking into it!

    ReplyDelete