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 sourceserverframework - Node.js is
free - Node.js runs on various platforms
(Windows, Linux, Unix, Mac OS X, etc.) - Node.js uses
JavaScripton 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 installornotopen CMD and type node -v and it shows the versioncurrent versionthats mean the nodejs is install perfectly on your machine - Now check the Node Package Manger(npm) is
installor 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.
createthe 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
browserand type in theurlyourloacl host addresshostname = '127.0.0.1' software using visual studio code(vscode editor) - And you get your first
Hello worldwebapp - when you type
wrong methodin theservercode the you dont get anyresponseon 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}/`);
});
