// Import 'http' module
const http = require('http');
// Create a simple HTTP server
const server = http.createServer((req, res) => {
res.end('Hello, Node.js!');
});
// Start the server and listen on port 3000
server.listen(3000, () => {
console.log('Server is listening on port 3000');
});Simple HTTP Server in Node.js
javascript
Related Posts
More content you might like
Tutorial
Build a Custom Rate Limiter in Node.js with Redis
If you're building any kind of real API, this knowledge will serve you well.
Have questions or want a follow-up tutorial? Leave a comment or reach out—we’d love to help.
Apr 04, 2025
Read More Tutorial
javascript css +1
Building a Real-Time Chat Application with WebSockets in Node.js
If you haven’t already installed Node.js, you can download it from the official website. Node.js includes npm, the package manager we will use to install dependencies.
mkdir websocket_chat
cd websocket_chatAug 03, 2024
Read More Code
php
JWT Token Creation and Verification in Node.js using 'jsonwebtoken'
No preview available for this content.
Jan 26, 2024
Read More Code
javascript
Read and Write Files in Node.js using 'fs' module
No preview available for this content.
Jan 26, 2024
Read MoreDiscussion 0
Please sign in to join the discussion.
No comments yet. Be the first to share your thoughts!