JavaScript is a high-level interpreter language known as the Web kernel. One of the most important desires of web developers has always been to be able to use JavaScript for server-side coding so that they do not have to go to languages such as PHP, Python, etc. to implement the application server. With the arrival of Node.js, this wish of the developers was fulfilled and now it is easy to use JavaScript and its unique power on the server-side. In this article, we are going to teach you to step by step How to Install Node.js on Fedora. You can see the packages available in Eldernode if you want to buy a Linux VPS server.
Table of Contents
Tutorial Install Node.js on Fedora [PPA way]
What is Node.js?
In 2009, a person named Ryan Dahl introduced Node.js. But what is the story of the creation of Node.js? Mr. Dahl first used the Ruby language for programming. But after seeing the progress bar on Flickr, which did not work properly, he thought that by connecting this progress bar to the server, he could take the exact amount of progress from the server in an instant and display it on the progress bar. For this purpose, the development of node js was started and Node js was introduced.
Node.js is a server-side platform based on the Google Chrome V8 JavaScript engine. With the creation of Node.js, it has been proven that JavaScript is more powerful than these words, and it can easily run JavaScript programs on the server. Node.js is also very suitable for implementing large and high-consumption applications and has the best performance.
Node.js Features
Some of the most important features of Node.js are:
1_ High efficiency and speed
2_ Node.js is a cross-platform
3_ Node.js has a good relationship with microservices
4_ Ability to create SPA programs (single page)
5_ Ability to create real-time programs
6_ Ability to create chat programs and online games
Install Node.js on Fedora Using PPA way
In this section, we are going to teach you how to install Node.js on Fedora using the PPA method. Before you start, you need to know that you must be a non-root user on the server and have Sudo privileges. Then you can follow the steps below in order.
First, you can run the following commands to make sure that the installer of the Fedora package, yum, has the most up-to-date information:
sudo yum check-update
sudo yum install
In the next step, you need to install the Curl tool. Note that if the Curl tool is included in your system packages, it does not need to be installed. The Curl tool is used to load and install PPA. In the following command you can replace “16.x” with any other option:
sudo curl -sL https://rpm.nodesource.com/setup_16.x | bash -
Finally, it should be noted that if you need to compile and install native addons from npm, you can install the build tools using the following commands:
yum install gcc-c++ make
or
yum groupinstall 'Development Tools'
After successful installation of Node.js, you can check the installed version by running the following command:
node --version
How to Run Demo HTTP Server
In this section, we are going to create a web server with the text “Welcome to Node.js“. You must create a demo_server.js file to do this. So open the configuration file with the text editor you want:
vim http_demo_server.js
Then you need to add the following content to the file:
var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Welcome to Node.js'); }).listen(3001, "127.0.0.1"); console.log('Server running at http://127.0.0.1:3001/');
Finally, you can start the webserver by running the following command:
node --inspect http_demo_server.js
Conclusion
Node.js follows an event-driven model. Also, this model does not block input and output processes at all, so using such a model makes the Node.js runtime environment light and efficient. In this article, we tried to teach you how to install Node.js on Fedora after its complete introduction and features. You can visit How to Install Node.js on Ubuntu, Debian, and CentOS if you wish.