[Episode one] Starting off with NodeJS for web development

Nodejs for web development

[Episode one] Starting off with NodeJS for web development

Web development has taken another trend actually, back in the days it was more of the casual creating of websites which even did not have a database talk less of websites which could handle data, it was more of sending data from the basic forms direct to the server with authentication of no type at all, then real time tech enthusiasts which were into the real business of website development decided to give a second thought towards restructuring the scope of designing websites and then BOOM! Website development took another stance.
Am not much of a story teller, My name is metro and i think am a software craftsman and technical writer, and for the purpose of this post, we would be starting off a series in NodeJs for website development, actually its a project we would be  working on, so if you have real time interests in building a web application with NodeJS then here is the right tutorial for you.

What is NodeJS?

In simple terms , NodeJS is a javascript framework which can be used for backend development (backend development actually refers to actions that take place which involves user interactions, but the user really do not see the logic behind them, now what do i mean?) an example of a backend development instance is when a user registers on a website and then Logins to his or her profile, actually there are several functions that make this happen which is not necessarily shown to the user.
So NodeJS is used for such functions and development, initially JavaScript was meant for just building interfaces until nodej was born out of the blues to also interact with servers.

  • Node.js is an open source server environment
  • Node.js is free
  • Node.js runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)
  • Node.js uses JavaScript on the server
READ  How to Preview and Selectively Backup WhatsApp on iPhone and Android?


For this NodeJS series the audience is centered towards those that have an interest in website development, and also enthusiasts which are ready to take up on any task given to them in the course of this series, furthermore added to your passion which i know you already have, you should have at least a basic understanding of HTML, Css and JavaScript, but in case you really are not familiar with them, then head over here to start with the basics. and then you should have a laptop.

READ  Mark zuckerberg underground secret escape chute beneath conf room

Starter Codes in NodeJS

For you to have continued reading, i suppose now that you are qualified and that you have a basic understanding of the pre-requisites listed above, now its time to get started, we would be writing our codes using best practices and also incorporating the ES6 standards which would give us a lot of room to explore our coding options.
Now for you to start coding in NodeJS you should have a code Editor, and also NodeJs installed on your computer system and then you will be ready to start with us.

What Can Node.js Do?

  • Node.js can generate dynamic page content
  • Node.js can create, open, read, write, delete, and close files on the server
  • Node.js can collect form data
  • Node.js can add, delete, modify data in your database

What is a Node.js File?

  • Node.js files contain tasks that will be executed on certain events
  • A typical event is someone trying to access a port on the server
  • Node.js files must be initiated on the server before having any effect
  • Node.js files have extension “.js”

Once you have downloaded and installed Node.js on your computer, let’s try to display “Hello World” in a web browser.
Create a Node.js file named “myfirst.js”, and add the following code:

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/html'});
  res.end('Hello World!');
Save the file on your computer: C:\Users\Your Name\myfirst.js

The code tells the computer to write “Hello World!” if anyone (e.g. a web browser) tries to access your computer on port 8080.
For now, you do not have to understand the code. It will be explained later.

READ  Email marketing exposes 800 million email entries and disappeared off the internet

Command Line Interface

Node.js files must be initiated in the “Command Line Interface” program of your computer.
How to open the command line interface on your computer depends on the operating system. For Windows users, press the start button and look for “Command Prompt”, or simply write “cmd” in the search field.
Navigate to the folder that contains the file “myfirst.js”, the command line interface window should look something like this:

C:\Users\Your Name>_

Initiate the Node.js File

The file you have just created must be initiated by Node.js before any action can take place.
Start your command line interface, write node myfirst.js and hit enter:

Initiate "myfirst.js":
C:\Users\Your Name>node myfirst.js

Now, your computer works as a server!
If anyone tries to access your computer on port 8080, they will get a “Hello World!” message in return!
Start your internet browser, and type in the address: http://localhost:8080


I am both a front and backend developer

View all posts

Add comment

Your email address will not be published. Required fields are marked *

DMCA.com Protection Status