NodeJsCreating Your First Node.js App

You can create a simple Node.js app by using the built-in 'http' module to set up a basic server. This server listens for requests and responds with a message, demonstrating the core of Node.js functionality.

const http = require('http');

const server = http.createServer((req, res) => {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello, Node.js!');
});

server.listen(3000, () => {
  console.log('Server running at http://localhost:3000');
});