How to install Node.js on Fedora Linux?


Node.js is an open-source, cross-platform JavaScript runtime environment designed to run JavaScript code on the server side.

It lets developers use JavaScript for server-side scripting to produce dynamic webpage content these pages are produced before they get displayed on a web browser.

As I already discussed how to install Node.js in Ubuntu.

Today in this article, we will discuss how to install Node.js in Fedora Linux

Prerequisites

To complete this installation guide you will need to have the following.

  • A system running a recent version of Fedora
  • Access to a user account with superuser privileges

How to install Node.js on Fedora

There are multiple different ways in which you can install Node.js on a Fedora system. You can use one of the given methods to install Node.js on your system.

Installing Node.js from the default Fedora repository

Node.js is available in the default repository of Fedora Linux. You can install it directly by using the dnf command in your terminal.

Before you install a package make sure your system packages are updated –

sudo dnf update -y

Next, use the given command to install Node.js on your system –

sudo dnf install nodejs 

Press y and then enter if it asks for your confirmation.

You can verify the installation by using the given command –

nodejs -v

Installing Node.js from its official repository

Node.js officially provides the latest packages for Fedora, you can add the official repository to your system to download it.

Use the following command to add the Node.js repository to your system.

For latest release

sudo dnf install -y gcc-c++ make curl 
curl -sL https://rpm.nodesource.com/setup_18.x | sudo -E bash - 

For stable release

sudo dnf install -y gcc-c++ make curl 
curl -sL https://rpm.nodesource.com/setup_16.x | sudo -E bash - 

After adding the repository to your system execute the following command to install Node.js to your system –

sudo dnf install nodejs -y

You can verify the installation by using –

nodejs --version

Installing Node.js using NVM

You can also use NVM or Node Version Manager to install Node.js on Fedora. This allows you to install and maintain different versions of Node.js and associated packages.

Now first install the nvm by using the given command in your terminal –

curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash 

Next, use the given command to source the .bashrc file –

source ~/.bashrc 

Use the given NVM command to display the available Node.js versions –

nvm list-remote | more

This will fetch and display the list of available versions for installation you can scroll and see the output using the enter key.

nodejs versions

To install a specific package of Node.js, use the following command in your terminal –

nvm install v16.14 

You can view the list of all installed Node.js versions by using –

nvm list

By using a command like this you can switch between two versions of Node.js –

nvm use 12.22.1

The above command will make Node.js 12.22.1 as default.

You can verify the Node.js version by using –

nodejs --version

Conclusion

By using one of the given methods you can install Node.js on your Fedora system.

Now if you have a query then write us in the comments below.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.