Install Latest Nodejs on Rocky Linux 8

0
70

In this tutorial, you will learn how to install latest Nodejs on Rocky Linux 8. Nodejs is a JavaScript runtime built on Chrome’s V8 JavaScript engine and is designed to build scalable network applications.

Install Latest Nodejs on Rocky Linux 8

Nodejs is available on the default Rocky Linux 8 AppStream repos. However, the available versions may not be up-to-date.

For example, in the command output below, you can see that Nodejs 10.x repo modules are enabled.

dnf module list nodejs
Rocky Linux 8 - AppStream
Name                             Stream                           Profiles                                                       Summary                                    
nodejs                           10 [d]                           common [d], development, minimal, s2i                          Javascript runtime                         
nodejs                           12                               common [d], development, minimal, s2i                          Javascript runtime                         
nodejs                           14                               common [d], development, minimal, s2i                          Javascript runtime                         

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

Install latest Nodejs YUM/DNF Repository

Therefore, to install the latest, which is Nodejs 16.x, which is the current stable release as per the Nodejs releases page, you need to install Nodejs Yum repository on Rocky Linux 8 by executing the command below;

curl -sL https://rpm.nodesource.com/setup_16.x | sudo -E bash -

Install Latest Nodejs on Rocky Linux 8

Once the repos are in place, you can now install latest Nodejs on Rocky Linux 8.

dnf install nodejs

Sample command output;

Dependencies resolved.
============================================================================================================================================================================
 Package                                   Architecture                  Version                                                    Repository                         Size
============================================================================================================================================================================
Installing:
 nodejs                                    x86_64                        2:16.4.0-1nodesource                                       nodesource                         31 M
Installing dependencies:
 python3-pip                               noarch                        9.0.3-19.el8.rocky                                         appstream                          19 k
 python3-setuptools                        noarch                        39.2.0-6.el8                                               baseos                            162 k
 python36                                  x86_64                        3.6.8-2.module+el8.3.0+120+426d8baf                        appstream                          18 k
Enabling module streams:
 python36                                                                3.6                                                                                               

Transaction Summary
============================================================================================================================================================================
Install  4 Packages

Total download size: 31 M
Installed size: 87 M
Is this ok [y/N]: y

Checking installed version of Nodejs on Rocky Linux 8;

node -v
v16.4.0

Note that the command above also installs NPM along with Nodejs. You can verify by checking the version of installed NPM on Rocky Linux 8.

npm -v
7.18.1

Install development tools to build native addons

If you need to build native Nodejs addons, you need to install some development tools by running the command below;

dnf install gcc-c++ make

Install Yarn on Rocky Linux 8

You may also want to install Yarn on Rocky Linux 8. To do so, run the command below:

curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
dnf install yarn

Conclusion

That marks the end of our tutorial on how to install latest Nodejs on Rocky Linux 8.

You can now proceed to build your web applications using Nodejs.

Read more on Nodejs getting started guide.

Other tutorials

Install PHP Composer on Rocky Linux 8

Install PHP 8.0 on Rocky Linux 8

LEAVE A REPLY

Please enter your comment!
Please enter your name here