Atlantic.Net Blog

How to Install Node.js and NPM on Oracle Linux

Node.js is a free and open-source JavaScript library that is used to build scalable network applications. It is built on Chrome’s V8 JavaScript engine and allows you to develop complex and very scalable web applications easily. Node.js is designed for the back-end application. However, you can also use it as a full-stack and front-end solution. It is cross-platform and runs on different platforms including Windows, Linux, Unix, and Mac OS X. It is simple, lightweight, and supports a non-blocking I/O model and event-driven architecture.

In this post, we will show you how to install Node.js and NPM on Oracle Linux 8.

Step 1 – Install Node.js Using Oracle Linux Repository

By default, Node.js is included in the Oracle Linux AppStream repository. You can list all available Node.js versions using the following command:

dnf module list nodejs

You should see the following output:

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  
nodejs    16        common [d], development, minimal, s2i   Javascript runtime  
nodejs    18        common [d], development, minimal, s2i   Javascript runtime  
nodejs    20        common, development, minimal, s2i       Javascript runtime

To install the Node.js version 20 from the above list, run the following command:

dnf module enable nodejs:20

Next, install the Node.js by running the following command:

dnf install nodejs -y

Once Node.js is installed, you can verify the Node.js version using the following command:

node --version

You will get the following output:

v20.0.0

To verify the NPM version, run the following command:

npm -v

Sample output:

10.1.0

Step 2 – Install Node.js From NodeSource Repository

By default, the latest version of Node.js is not available in the Oracle Linux 8 default repo, so you can use the NodeSource repository to install the latest version of Node.js.

First, install the curl command utility with the following command:

dnf install curl -y

Next, add the NodeSource repository for version 17 using the following command:

curl -sL https://rpm.nodesource.com/setup_17.x | bash -

To install the latest Node.js version, run the following command:

dnf install nodejs

After the installation, verify the Node.js version with the following command:

node -v

You should see the following output:

v17.9.0

To verify the NPM version, run the following command:

npm -v

You should see the following output:

8.5.5

Step 3 – Install Node.js Using NVM

NVM stands for Node Version Manager, which provides an easy way to install and manage multiple Node.js versions in the same system.

To install NVM, run the following command:

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

This command will install NVM to your system and add the NVM path to the .bashrc file.

Next, activate the NVM system path using the following command:

source ~/.bashrc

You can now verify the NVM version using the following command:

nvm --version

You should see the following output:

0.35.3

To install the latest Node.js version, run the following command:

nvm install node

You should see the following output:

Downloading and installing node v18.3.0...
Downloading https://nodejs.org/dist/v18.3.0/node-v18.3.0-linux-x64.tar.xz...
####################################################################################################################################### 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v18.3.0 (npm v8.11.0)
Creating default alias: default -> node (-> v18.3.0)

To install the latest stable Node.js version, run the following command:

nvm install --lts

You should see the following output:

Installing latest LTS version.
Downloading and installing node v16.15.1...
Downloading https://nodejs.org/dist/v16.15.1/node-v16.15.1-linux-x64.tar.xz...
####################################################################################################################################### 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v16.15.1 (npm v8.11.0)

To list all Node.js versions installed in your system, run the following command:

nvm ls

You should see the following output:

->     v16.15.1
        v18.3.0
         system
default -> node (-> v18.3.0)
node -> stable (-> v18.3.0) (default)
stable -> 18.3 (-> v18.3.0) (default)

To set the default Node.js version, run the following command:

nvm use 18.3.0

You should see the following output:

Now using node v18.3.0 (npm v8.11.0)

Conclusion

This guide taught us how to install Node.js using three different ways on Oracle Linux 8. You can now choose your preferred method to install the Node.js on Oracle Linux 8. Give it a try on your dedicated server from Atlantic.Net!

Get a $250 Credit and Access to Our Free Tier!

Free Tier includes:
G3.2GB Cloud VPS a Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year