Node.js has revolutionized server-side JavaScript development. Built on Chrome's V8 engine, it allows developers to run JavaScript outside the browser — opening up a world of possibilities for building fast, scalable network applications.
Why Node.js?
Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. This makes it perfect for data-intensive real-time applications that run across distributed devices.
Installing Node.js
Head over to nodejs.org and download the LTS version for your platform. The installer includes npm (Node Package Manager) which you'll use to manage dependencies.
node -v
npm -vYour First App
Create a file called app.js and add the following:
const http = require('http');
const server = http.createServer((req, res) => {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello, World!');
});
server.listen(3000);Run it with node app.js and visit http://localhost:3000.