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: 1] Introduction to JavaScript - September 27, 2024
- Which is the Best Operating System for Programming? Here are 3 OS to Consider - August 24, 2024
- Top 10 Cybersecurity Threats to Watch Out for in 2024 - August 17, 2024
Pingback: Modules In NodeJs | Node.Js Tutorial #2 - Mr Programmer
Pingback: What is Node Package Manager? | Node.Js Tutorial #3 - Mr Programmer