Ads

NodeJS Tutorial Day 1

Learning Objective:┬áLet’s explore NodeJS and Learn everything about NodeJS Programming, NodeJS App Development, and Deployment.


What is NodeJS?

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. Source Wikipedia


How to Install NodeJS?

NodeJS Download Use this link to install NodeJS on the Latest operating system, If you are using older operating systems like Windows 7 then search like NodeJS for Windows 7


How to Check My Installation is Done or not?

Goto Command Prompt or Terminal and execute the following command, if you get some result on both commands your installation is perfect, if you get an error like command not found then your installation is not done properly.

node -v

npm -v


NodeJS Hello World Program.

Create Folder: C:\NodeJSProgram

Open Visual Studio Code and open this folder

Create a new File named: n1.js

write down the following code

var http = require('http');

http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World!');
}).listen(8080);

Open Terminal with Folder “C:\NodeJSProgram” and run the following command

node n1.js

Goto Browser and open the following URL

http://localhost:8080/

Ads