Getting Started NodeJS + Writing Hello World! | Node.Js Tutorial #1

Getting Started NodeJS + Writing Hello World! | Node.Js Tutorial #12 min read

Hey Programmers, In this Post We Will Starting With Node.js And In Further Post We will be Working With Node.Js Modules And Other Things Like HTTP Module, Console, MySQL Linking With Node.js, Creating DataBase, File System, And More. Before Working With Node.js First Make Sure Node.Js Is Installed In your System.

Table Of Contents:

  • What is Node.js?
  • Installing Node.js
  • Creating a Baisc HTTP Server Using HTTP Module
  • Conclusion

What is Node.js?

2560px Node.js logo 2015.svg

Node.js is an open-source, cross-platform, back-end JavaScript runtime environment that runs on a JavaScript Engine and executes JavaScript code outside a web browser, which was designed to build scalable network applications.

What is NodeJS used for?

Nodejs is mainly used for non-blocking event servers, due to its single-threaded nature. It is used for traditional websites and back-end API services, but is designed with real-time push architectures in mind.

Installing Node.js

Step 1: Go to Node.js Official Website Which is https://nodejs.org/ And Download Your Version Of Node.js According To Your Operating System.

Step 2: Run the Node.js Setup And Install It With the Default Settings:

image

Once You Have Installed Node.js Click On the Finish Button.

HTTP Module In Node.js

In Node.js, There is a Bult-In Module Called HTTP (Hyper Text Transfer Protocol) Which Allows Us to Listen to Server Ports & Give the Responce Back to the Client.

Use the createServer() method to create a HTTP Server::

var http = require('http')

// Create a Basic Web Server
http.createServer(function (req, res){
  res.write('Hello World!');
  res.end();
}).listen(3000);

Output:

image 1

Conclusion

From this We Have Installed Node.js + Created Our First Program In Node.js, So this was It for this Post Se you In the Next One Till then Keep Coding Keep Exploring!

Tanmay Sinha

Author

  • Tanmay Sinha

    Founder & CEO of MrProgrammer.in | I help Learning Freaks to Step into the World of Programming and Our Mission is to Provide High Quality and Valuable Content to Our Users! We believe that everyone has the potential to learn to code, and we are committed to making that happen. Our courses are designed to be engaging and interactive, and we offer a variety of learning paths to meet the needs of all learners. We are also committed to providing our learners with the support they need to succeed, and we offer a variety of resources to help learners learn at their own pace. If you are interested in learning to code, we encourage you to check out our courses. We are confident that you will find our content to be high-quality, valuable, and makes sense.