Node.js
Tutorial
Simply put, Node.js is JavaScript running on the server.
Node.js is a platform built on the Chrome JavaScript runtime.
Node.js is an event-driven I/O server-side JavaScript environment based on Google's V8 engine. The V8 engine executes JavaScript at a very fast speed, offering excellent performance.
Who is this tutorial for?
If you are a frontend programmer and you don't know dynamic programming languages like PHP, Python, or Ruby, but you want to create your own services, then Node.js is a great choice.
Node.js is JavaScript running on the server. If you are familiar with JavaScript, you will find it easy to learn Node.js.
Of course, if you are a backend programmer and want to deploy some high-performance services, learning Node.js is also a great choice.
What you need to know before learning this tutorial
Before continuing with this tutorial, you should understand some basic computer programming terms. If you have learned programming languages like JavaScript, PHP, Java, etc., it will help you understand Node.js programming more quickly.
Version in use
We can check the current Node version using the following command:
$ node -v
v4.4.3
Note: There may be differences between versions.
First Node.js Program: Hello World!
Script Mode
Here is our first Node.js program:
Example
console.log("Hello World");
Save this file with the name helloworld.js and execute it using the node command:
node helloworld.js
If the program executes correctly, it will output "Hello World" in the terminal.
Interactive Mode
Open the terminal and type node
to enter the command interactive mode. You can input a code statement and see the result immediately, for example:
$ node
> console.log('Hello World!');
Hello World!
Gif Demonstration
Next, we will demonstrate the example operation through a Gif image: