Plan du site  
pixel
pixel

Articles - Étudiants SUPINFO

NodeJS-Introduction and Installation in Windows Environment

Par Jingwei BAI Publié le 10/01/2019 à 17:51:12 Noter cet article:
(0 votes)
En attente de relecture par le comité de lecture

Preview

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 Preview

1.1.1 What is NodeJS?

1.1.2 What is non blocking?

1.2 Installation

1.2.1 Download resource

1.2.2 Installation

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

1.4 Conclusion

1.5 Bibliography

what is NodeJS ?

In a word, Node.js is JavaScript that runs on the server side. It is a JavaScript runtime environment (it can execute js code): but NodeJS is not a language or a library, a framework.

NodeJS has the features:

  1. Node.js is a platform built on the Chrome JavaScript runtime.

  2. Node.js is an event-driven I/O server-side JavaScript environment. Remember event-driven I/O, it is the core feature. Based on Google's V8 engine, the V8 engine executes JavaScript very fast and performs very well.

  3. NodeJS is also known as a non-blocking IO model, (we will discuss that in the following chapter).

  4. Lightweight and efficient.

Non blocking

we have mentioned that non-blocking as an example for the one of the NodeJS core feature. But how to understand what is non blocking?

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 event-driven.

Non-blocking can significantly improve program performance and reduce program waiting time.

Installation

Download resource

The Node.js installation package and source code download address is: https://nodejs.org/en/download/.

You can choose the Node.js installation package you need for different platform systems.

Installation

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.

Optional configuration

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 that.

Test your NodeJS

check out the version

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 directory.

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 installation successfully.

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:

  1. Introducing the required module: We can use the require directive to load the Node.js module.

  2. Create a server: The server can listen to client requests, similar to HTTP servers such as Apache and Nginx.

  3. 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 request.

Now, you have already installed NodeJS. It is time to set up your first NodeJS project to get a feeling of the NodeJS powerful features.

Step 1 : You create a new server.js under the directory of \nodejs\

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 running!".

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 of NodeJS:

  1. The first line requests (requires) the HTTP module : It comes with Node.js and assigns it to the HTTP variable.

  2. 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.

Conclusion

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 workplace.

Bibliography

https://nodejs.org/api/repl.html

http://maxprog.net.pl/node-js/node-js-server-architecture/

A propos de SUPINFO | Contacts & adresses | Enseigner à SUPINFO | Presse | Conditions d'utilisation & Copyright | Respect de la vie privée | Investir
Logo de la société Cisco, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société IBM, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Sun-Oracle, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Apple, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Sybase, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Novell, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Intel, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Accenture, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société SAP, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Prometric, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo de la société Toeic, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management Logo du IT Academy Program par Microsoft, partenaire pédagogique de SUPINFO, la Grande École de l'informatique, du numérique et du management

SUPINFO International University
Ecole d'Informatique - IT School
École Supérieure d'Informatique de Paris, leader en France
La Grande Ecole de l'informatique, du numérique et du management
Fondée en 1965, reconnue par l'État. Titre Bac+5 certifié au niveau I.
SUPINFO International University is globally operated by EDUCINVEST Belgium - Avenue Louise, 534 - 1050 Brussels