Write the app.js file
app.js code.
You may run this in your favorite Editor - I am using VS Code pre-installed with Node.js preinstalled.
Run the below command in powershell 7+ on Windows 10/11 as an Administrator.
# installs fnm (Fast Node Manager)
winget install Schniz.fnm
# configure fnm environment
fnm env --use-on-cd | Out-String | Invoke-Expression
# download and install Node.js
fnm use --install-if-missing 23
# verifies the right Node.js version is in the environment
node -v # should print `v23.3.0`
# verifies the right npm version is in the environment
npm -v # should print `10.9.0`
Now in VSCode - Copy and paste the following file with the name app.js
// app.js
// Load HTTP module
const http = require("http");
// Define the hostname and port
const hostname = "127.0.0.1";
const port = 3000;
// Create an HTTP server
const server = http.createServer((req, res) => {
// Set the response HTTP header with HTTP status and Content type
res.statusCode = 200;
res.setHeader("Content-Type", "text/plain");
// Send the response body "Hello, World!"
res.end("Hello, World!\n");
});
// Make the server listen to requests on port 3000
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
CTRL + F5 - Run without Debugging.
Launch a web browser and type:
Result of the Output:

6