in ,

Install NodeJS On Centos Stream And Ubuntu Using 3 Simple Ways

Installing Nodejs Centos Stream And Ubuntu

We will try to install Nodejs and Node Package Manager on the Centos Stream, and Ubuntu servers.

Install Nodejs On Centos Stream

Update the Centos Stream Server

# dnf update

Install Nodejs And The Node Package Manager

# dnf insatll nodejs npm

The above command will install the default nodejs package…
But we can select one of the available versions from the appstream repository as the following

# dnf module list nodejs
Last metadata expiration check: 0:12:16 ago on Sat 05 Mar 2022 11:43:39 PM UTC.
CentOS Stream 8 - AppStream
Name                                Stream                                 Profiles                                                          Summary
nodejs                              10 [d][e]                              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

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

you can notice that nodejs version 10 is the default and enabled version, so to install nodejs v16 you will need to reset the current version then enable and switch to v16 as the following

# dnf module reset nodejs
# dnf module enable nodejs:16

Then Install your preferred nodejs v16 as the following

# dnf module install nodejs:16/common

Install Nodejs On Ubuntu

Update the Ubuntu server

# apt update
# apt upgrade

Install The Nodejs And The Node Package Manager

# apt install nodejs npm
Check the nodejs version...
# nodejs --version
v10.19.0

Installing Using NVM The Node Version Manager (Common Method)

Download the latest NVM version and pass it to bash as the following command

# curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
# source ~/.bashrc

Then select your preferred nodejs version to install, you can list all available versions using

# nvm ls-remote

The output will be similar to

       v15.14.0
        v16.0.0
        v16.1.0
        v16.2.0
        v16.3.0
        v16.4.0
        v16.4.1
        v16.4.2
        v16.5.0
        v16.6.0
        v16.6.1
        v16.6.2
        v16.7.0
        v16.8.0
        v16.9.0
        v16.9.1
       v16.10.0
       v16.11.0
       v16.11.1
       v16.12.0
       v16.13.0   (LTS: Gallium)
       v16.13.1   (LTS: Gallium)
       v16.13.2   (LTS: Gallium)
       v16.14.0   (Latest LTS: Gallium)
        v17.0.0
        v17.0.1
        v17.1.0
        v17.2.0
        v17.3.0
        v17.3.1
        v17.4.0
        v17.5.0
        v17.6.0

So I will install v17.6.0 using…

# nvm install v17.5.0
Downloading and installing node v17.5.0...
Local cache found: ${NVM_DIR}/.cache/bin/node-v17.5.0-linux-x64/node-v17.5.0-linux-x64.tar.xz
Checksums match! Using existing downloaded archive ${NVM_DIR}/.cache/bin/node-v17.5.0-linux-x64/node-v17.5.0-linux-x64.tar.xz
Now using node v17.5.0 (npm v8.4.1)
Creating default alias: default -> v17.5.0

Install Nodejs Using NodeSource

Another simple way to install Nodejs is using NodeSource packages, which maintains PPA Personal Package Archive.

We will need to select our preferred Nodejs version to install its PPA from here and install as the following

If we need to install Nodejs v17

NodeSource For Ubuntu

# curl -fsSL https://deb.nodesource.com/setup_17.x | -E bash -
# apt-get install -y nodejs

NodeSource For Centos Stream

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

What do you think?

Leave a Reply

Your email address will not be published.

Python

Installing Python On Linux Centos Stream 8

Python Virtual Environment

Python Virtualenv On Windows