Hi, I'm MalekBenz. I author this blog, I'm FullStack Developer, create courses & love learning, writing, teaching technology. ( Javascript, C#, ASP.NET , NodeJS, SQL Server )

First web application with Nodejs

Node js is great for creating web application. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient.

In this post we are going to build our first web application, a HelloWeb application. if you don’t have node js already installed you can Install & run your first application Nodejs.

Create my first web application

Create a folder ‘HelloWeb’

    $ mkdir  HelloWeb

And within a folder create a file ‘app.js’


We use Visual studio code you can use your editor of choice

    const http = require('http');

    const hostname = '';
    const port = 3000;

    const server = http.createServer((req, res) => {
    res.statusCode = 200;
    res.setHeader('Content-Type', 'text/plain');
    res.end('Hello World!\n');

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

vs code

Run the application

Run the application with the following command:

   $ node app.js

The app starts a server and listens on port 3000 for connections. The app responds with “Hello World!”.

vs code

load http://localhost:3000/ in a browser to see the output.

vs code

your First web application with Nodejs is working