Articles - Étudiants SUPINFO
In this article you will learn basic concept of NodeJS, its core
feature, and manage to set up your first sample project with NodeJS.
The structure of this article is as below.
1.1.1 What is NodeJS?
1.1.2 What is non blocking?
1.2.1 Download resource
1.2.3 Optional configuration
1.3 Test your NodeJS
1.3.1 Check the version
1.3.2 Create your first NodeJS sample project
is not a language or a library, a framework.
NodeJS has the features:
environment. Remember event-driven I/O, it is the core feature.
fast and performs very well.
NodeJS is also known as a non-blocking IO model, (we will
discuss that in the following chapter).
Lightweight and efficient.
we have mentioned that non-blocking as an example for the one of
the NodeJS core feature. But how to understand what is non
The execution of blocking is performed in order, waiting for the
returned results and continuing to the next thread.
For the non-blocking, you don't have to wait for the returned
results, NodeJS will execute to the next step directly.
We can see that non-blocking is as a result of taking the
Non-blocking can significantly improve program performance and
reduce program waiting time.
The Node.js installation package and source code download address
You can choose the Node.js installation package you need for
different platform systems.
When you have downloaded the NodeJS, you should find out the
directory and open it,
and choose the disk you want to install.
Next step, it will be installed in seconds. Notice this option
"npm package manager", we will use it frequently in the future.
At last, installation is finished.
There are lots of tutorial that suggests to add the NodeJS path to
the system variable. In fact, it is not necessary. It will make the mess
if you are the starter in the system learning. So I do not suggest to do
After installation, you need to make sure that whether the NodeJS
is under installation successfully or not. So, you can execute the
command "node -- version" to do this task.
At first, you need to open the CMD tool if your operating system
is Windows. Then you will enter at the root directory like below.
Remember you are working at Windows Environment, it is different
than the Linux. So you have to change the directory to D:\ because the
NodeJS is installed there. Use the command "D:" to change the
Now you are in the directory right here. Execute the command "node
--version" to check the status of NodeJS installation If the CMD returns
like below with a prefix "v", it means that you have already made the
create your first NodeJS sample project
Before we create the first test program for Node.js, let's
understand the parts of the Node.js application are made up of:
Introducing the required module: We can use the require
directive to load the Node.js module.
Create a server: The server can listen to client requests,
similar to HTTP servers such as Apache and Nginx.
Receiving Requests and Response Requests The server is easy to
create. The client can send an HTTP request using a browser or
terminal. The server returns the response data after receiving the
Now, you have already installed NodeJS. It is time to set up your
first NodeJS project to get a feeling of the NodeJS powerful
Step 1 : You create a new server.js under the directory of
Step 2 : After creating the server.js file, you should open CMD
and change the directory to D:\nodejs\.
And then, you run the command "node server.js", this action will
start to run the server.js on the NodeJS server. The notice will be
shown as below.
Step 3 : Next, you open a browser and visit http://127.0.0.1:1212/
and you will see a page with "Your first NodeJS sample program is
Now we have finished all the procedure of installation. Let us
consider one thing, why the browser displays the page?
To find out this question, we have to understand the HTTP Server
The first line requests (requires) the HTTP module : It comes
with Node.js and assigns it to the HTTP variable.
Next we call the function provided by the HTTP module:
createServer(). This function returns an object with a method called
listen . This method takes a numeric argument specifying the port
number that the HTTP server listens on.
There are many tutorial on the Internet for starter how to install
NodeJS, but some of them ignore the details in installation which may be
the most important for beginner. This article describes the whole
procedure of installation for NodeJS. And every step we mentioned is
significant if you are just starting to learn how to use NodeJS in your