Java, .NET, PHP, PYTHON, ANGULAR, ML, Data Science, Testing, CI Tutorials in Easy Languages.

"Best Software Training, Internship, Project Development center of Indore India, Helpline 780506-3968"

 What is Node JS?


Node Js is the advanced dynamic library of Javascript that is used to manage dynamic operation using JS library, it is used to implement backend operation under Angular or React application hence.

NODE js is the primary layer of angular and react application, without node environment we can not create the React and Angular application.



Node JS also used to handle file handling operations, we can read, write, append data from text files and binary files.


NODE js is mainly used to connect data from database servers such as Mongo DB and MYSQL.


NODE Js used server to run the script we can save the file using .js or .ts extension both.


Now I am providing the first program of Node Js to print hello world?


Step1st:- Install Node Js in Machine using the following link

                https://nodejs.org/en/download/


Step2nd:-  Check node js is installed in the machine or not

                 node -v


Step3rd:-   Write code on Node Js under notepad or vs code or sublime text


   var http = require("http");

http.createServer(function (request, response) {

   // Send the HTTP header 

   // HTTP Status: 200 : OK

   // Content Type: text/plain

   response.writeHead(200, {'Content-Type': 'text/plain'});

   

   // Send the response body as "Hello World"

   response.end('Hello World\n');

}).listen(8081);


// Console will print the message

console.log('Server running at http://127.0.0.1:8081/');


             

here cosole.log display server URL under command prompt.


Open a command prompt and write the following code


node filname.ts


Another Example of Node Js?


How to write content on File using NODE JS?

var fs = require("fs");

var data = fs.readFileSync('efixman.txt');


console.log(data.toString());

console.log("Program Ended");



ASSIGNMENT?


CREATE Biodata using file operation on Node JS?

Calculate Simple Interest using NODE JS and Write-Output data on file?

WAP to swap two numbers in node js and display the result on file?





Post a Comment

If you have any doubt in programming or join online classes then you can contact us by comment .

Previous Post Next Post