how to create a server in node js

// Step 1: Import the 'http' module
const http = require('http');

// Step 2: Create a server using the http module
const server = http.createServer((req, res) => {
  // Step 3: Set the response header with a status code of 200 and content type of 'text/plain'
  res.writeHead(200, {'Content-Type': 'text/plain'});

  // Step 4: Send a response message to the client
  res.end('Hello, this is a simple Node.js server!\n');
});

// Step 5: Specify the port number on which the server will listen
const port = 3000;

// Step 6: Make the server listen on the specified port
server.listen(port, () => {
  console.log(`Server listening on port ${port}`);
});