this is the tutorial of node js . In Which you can learn the nodejs and apply on the projects..Happy Coding
About NodeJS
- Node.js is an
open source
serverframework
- Node.js is
free
- Node.js runs on various platforms
(Windows, Linux, Unix, Mac OS X, etc.)
- Node.js uses
JavaScript
on the server
Follow the step to Install the Nodejs on Windows..
- Open the browser And Type Nodejs Downlod
- And download current version of the Nodejs.
- Now check the
nodejs is install
ornot
open CMD and type node -v and it shows the versioncurrent version
thats mean the nodejs is install perfectly on your machine - Now check the Node Package Manger(npm) is
install
or not Repeat above steps and open cmd type npm -v.
Node.js is a platform built on Chrome's JavaScript runtime for easily building fast and scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
create
the file has .jsextension
.- type the below code nodejs server code
const http = require('http');
const hostname = '127.0.0.1';
const port = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World\n');
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
- for start the server type the node application name or file name
- now open the
browser
and type in theurl
yourloacl host address
hostname = '127.0.0.1' software using visual studio code(vscode editor) - And you get your first
Hello world
webapp
- when you type
wrong method
in theserver
code the you dont get anyresponse
on thewebpage
.
const http = require('http');
const hostname = '127.0.0.1';
const port = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
---> res.endd('Hello World\n');
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});