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?
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:
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:
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!
- The JS Developer’s Podcast [EP: 2] Variables and Data Manipulation - October 15, 2024
- YouTube Channels to Learn Coding: Top 9 Picks That Will Make a You Master - October 10, 2024
- The JS Developer’s Podcast [EP: 1] Introduction to JavaScript - September 27, 2024
Pingback: Modules In NodeJs | Node.Js Tutorial #2 - Mr Programmer
Pingback: What is Node Package Manager? | Node.Js Tutorial #3 - Mr Programmer