Without any further ado, let's get our hand dirty with the Node.js.
Installation
1 Download and install Node.js from the official website.
2 Create a Simple Server:
Save the following code in a file named app.js:
const http = require('http');
const server = http.createServer((req, res) => {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello, Node.js!\n');
});
server.listen(3000, () => {
console.log('Server running at http://localhost:3000/');
});
3 Run the Application:
Open the terminal, navigate to your project directory, and execute:
node app.js
4 View in Browser:
Open your browser and visit: http://localhost:3000
to see the Node.js application in action.