Node.js is an asynchronous event-driven JavaScript runtime built on Chrome’s V8 JavaScript engine. It is designed to build scalable network applications and backend servers.
Node.js liberates JavaScript from the browser, allowing you to interact with file systems, deploy HTTP servers, and query databases.
Node uses an event-loop to handle thousands of concurrent requests incredibly quickly without waiting for data functions to finish.
Node comes with NPM, giving you immediate access to the largest registry of pre-written software packages in the world.
To use Node, you must download the runtime engine onto your computer, enabling the "node" command locally.
1// server.js
2const http = require('http');
3
4const server = http.createServer((req, res) => {
5 res.statusCode = 200;
6 res.end('Hello World Backend
7');
8});
9
10server.listen(3000, () => {
11 console.log('Server running on port 3000');
12});
13
14// Run it using your terminal:
15// node server.js