Step 1 – Setup Dnf Repository
First of all, You need to enable node.js yum repository in your system provided by the Node.js official website. You also need development tools to build native add-ons to be installed on your system.
For Latest Release:-
1 2 |
sudo dnf install -y gcc-c++ make curl -sL https://rpm.nodesource.com/setup_12.x | sudo -E bash - |
For Stable Release:-
1 2 |
sudo dnf install -y gcc-c++ make curl -sL https://rpm.nodesource.com/setup_10.x | sudo -E bash - |
Step 2 – Install Node.js on Fedora
After adding yum repository in your system lets install Node.js package. NPM will also be installed with node.js. This command will also install many other dependent packages on your system.
1 |
sudo dnf install nodejs |
Step 3 – Check Node.js and NPM Version
After installing node.js verify and check the installed version. You can find more details about current version on node.js
1 2 3 |
node --version v12.8.0 |
Also, check the npm version installed on your Fedora system.
1 2 3 |
npm --version 6.10.2 |
Step 4 – Run Demo HTTP Server (Optional)
This is an optional step. If you want to test your node.js install. Let’s create a web server with “Welcome Node.js” text. Create a file demo_server.js
1 |
vim http_demo_server.js |
and add the following content
1 2 3 4 5 6 |
var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end(' WELCOM - - -- kutayzorlu.com '); }).listen(3001, "127.0.0.1"); console.log('Server running at http://127.0.0.1:3001/'); |
Now start the web server using the command.
1 2 3 4 |
node --debug http_demo_server.js debugger listening on port 5858 Server running at http://127.0.0.1:3001/ |