How to install NodeJS on Centos


In this tutorial, we use CentOS 6.8 64bits – CentOS 7 64bits – CentOS 8.2 64bits.

Step Prepare: install epel-release and curl

yum install -y epel-release curl

Step 1:

1.a: If you Install NodeJS v4:

curl --silent --location https://rpm.nodesource.com/setup_4.x | bash -

Result:

[root@tutorialspots ~]# curl --silent --location https://rpm.nodesource.com/setup_4.x
| bash -

## Installing the NodeSource Node.js v4.x LTS Argon repo...


## Inspecting system...

+ rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release |
| rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release
+ uname -m

## Confirming "el6-x86_64" is supported...

+ curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_4.x/el/6/x86_64/nodesou
rce-release-el6-1.noarch.rpm'

## Downloading release setup RPM...

+ mktemp
+ curl -sL -o '/tmp/tmp.PCr0yN2Ra3' 'https://rpm.nodesource.com/pub_4.x/el/6/x86
_64/nodesource-release-el6-1.noarch.rpm'

## Installing release setup RPM...

+ rpm -i --nosignature --force '/tmp/tmp.PCr0yN2Ra3'

## Cleaning up...

+ rm -f '/tmp/tmp.PCr0yN2Ra3'

## Checking for existing installations...

+ rpm -qa 'node|npm' | grep -v nodesource
XNode.js v4.x LTS Argon == XNode.js v5.x

## Run `yum install -y nodejs` (as root) to install Node.js v4.x LTS Argon and n
pm.
You may also need development tools to build native addons:
  `yum install -y gcc-c++ make`

install nodejs centos

1.b: If you Install NodeJS v6:

curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -

Result:

[root@tutorialspots ~]# curl --silent --location https://rpm.nodeso
urce.com/setup_6.x | bash -

## Installing the NodeSource Node.js 6.x repo...


## Inspecting system...

+ rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release |
| rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release
+ uname -m

## Confirming "el7-x86_64" is supported...

+ curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_6.x/el/7/x86_64/nodesou
rce-release-el7-1.noarch.rpm'

## Downloading release setup RPM...

+ mktemp
+ curl -sL -o '/tmp/tmp.SiXHbzxSik' 'https://rpm.nodesource.com/pub_6.x/el/7/x86
_64/nodesource-release-el7-1.noarch.rpm'

## Installing release setup RPM...

+ rpm -i --nosignature --force '/tmp/tmp.SiXHbzxSik'

## Cleaning up...

+ rm -f '/tmp/tmp.SiXHbzxSik'

## Checking for existing installations...

+ rpm -qa 'node|npm' | grep -v nodesource

## Run `yum install -y nodejs` (as root) to install Node.js 6.x and npm.
## You may also need development tools to build native addons:
##   `yum install -y gcc-c++ make`

1.c: If you Install NodeJS 8.x:

curl --silent --location https://rpm.nodesource.com/setup_8.x | bash -

1.d: If you Install NodeJS 10.x:

curl --silent --location https://rpm.nodesource.com/setup_10.x | bash -

Result: (Example on CentOS 7)

[root@tutorialspots ~]# curl --silent --location https://rpm.nodesource.com/setup_10.x | bash -

## Installing the NodeSource Node.js 10.x repo...


## Inspecting system...

+ rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release || rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release
+ uname -m

## Confirming "el7-x86_64" is supported...

+ curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_10.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'

## Downloading release setup RPM...

+ mktemp
+ curl -sL -o '/tmp/tmp.9ULAqlDzrl' 'https://rpm.nodesource.com/pub_10.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'

## Installing release setup RPM...

+ rpm -i --nosignature --force '/tmp/tmp.9ULAqlDzrl'

## Cleaning up...

+ rm -f '/tmp/tmp.9ULAqlDzrl'

## Checking for existing installations...

+ rpm -qa 'node|npm' | grep -v nodesource

## Run `sudo yum install -y nodejs` to install Node.js 10.x and npm.
## You may also need development tools to build native addons:
     sudo yum install gcc-c++ make
## To install the Yarn package manager, run:
     curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
     sudo yum install yarn
...

1.e: If you Install NodeJS 0.10:

curl --silent --location https://rpm.nodesource.com/setup | bash -

1.f: If you Install NodeJS 14.x:

curl --silent --location https://rpm.nodesource.com/setup_14.x | bash -

Result: (Example on CentOS 8)

[root@tutorialspots ~]# curl --silent --location https://rpm.nodesource.com/setup_14.x | bash -

## Installing the NodeSource Node.js 14.x repo...


## Inspecting system...

+ rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release || rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release
+ uname -m

## Confirming "el8-x86_64" is supported...

+ curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_14.x/el/8/x86_64/nodesource-release-el8-1.noarch.rpm'

## As yum will try to install Node.js from the AppStream repository
instead of the NodeSource repository, the AppStream's version of Node.js has to be disabled.
## Run `sudo yum module enable -y nodejs` to reactivate the AppStream's Node.js repository.

+ yum module disable -y nodejs
Last metadata expiration check: 0:07:44 ago on Mon 05 Oct 2020 02:26:42 PM UTC.
Dependencies resolved.
================================================================================
 Package           Architecture     Version             Repository         Size
================================================================================
Disabling modules:
 nodejs

Transaction Summary
================================================================================

Complete!

## Downloading release setup RPM...

+ mktemp
+ curl -sL -o '/tmp/tmp.Y4SmdKIhEC' 'https://rpm.nodesource.com/pub_14.x/el/8/x86_64/nodesource-release-el8-1.noarch.rpm'

## Installing release setup RPM...

+ rpm -i --nosignature --force '/tmp/tmp.Y4SmdKIhEC'

## Cleaning up...

+ rm -f '/tmp/tmp.Y4SmdKIhEC'

## Checking for existing installations...

+ rpm -qa 'node|npm' | grep -v nodesource

## Run `sudo yum install -y nodejs` to install Node.js 14.x and npm.
## You may also need development tools to build native addons:
     sudo yum install gcc-c++ make
## To install the Yarn package manager, run:
     curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
     sudo yum install yarn

Step 2:

yum -y install nodejs

or

sudo yum --enablerepo=nodesource install nodejs -y

Result:

[root@tutorialspots ~]# yum -y install nodejs
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
epel/metalink                                            |  13 kB     00:00
 * base: mirror.trouble-free.net
 * epel: mirror.us.leaseweb.net
 * extras: mirror.netdepot.com
 * remi: repo1.ash.innoscale.net
 * remi-php55: repo1.ash.innoscale.net
 * remi-php56: repo1.ash.innoscale.net
 * remi-test: repo1.ash.innoscale.net
 * updates: mirrors.tripadvisor.com
base                                                     | 3.7 kB     00:00
extras                                                   | 3.4 kB     00:00
nginx                                                    | 2.9 kB     00:00
nodesource                                               | 2.5 kB     00:00
nodesource/primary_db                                    |  32 kB     00:00
remi                                                     | 2.9 kB     00:00
remi-debuginfo                                           | 2.9 kB     00:00
remi-php55                                               | 2.9 kB     00:00
remi-php55-debuginfo                                     | 2.9 kB     00:00
remi-php56                                               | 2.9 kB     00:00
remi-php56-debuginfo                                     | 2.9 kB     00:00
remi-test                                                | 2.9 kB     00:00
remi-test-debuginfo                                      | 2.9 kB     00:00
updates                                                  | 3.4 kB     00:00
vesta                                                    | 2.9 kB     00:00
Resolving Dependencies
--> Running transaction check
---> Package nodejs.x86_64 1:4.6.1-1nodesource.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package      Arch         Version                       Repository        Size
================================================================================
Installing:
 nodejs       x86_64       1:4.6.1-1nodesource.el6       nodesource       8.7 M

Transaction Summary
================================================================================
Install       1 Package(s)

Total download size: 8.7 M
Installed size: 29 M
Downloading Packages:
nodejs-4.6.1-1nodesource.el6.x86_64.rpm                  | 8.7 MB     00:01
warning: rpmts_HdrFromFdno: Header V4 RSA/SHA1 Signature, key ID 34fa74dd: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL
Importing GPG key 0x34FA74DD:
 Userid : NodeSource <gpg-rpm@nodesource.com>
 Package: nodesource-release-el6-1.noarch (installed)
 From   : /etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : 1:nodejs-4.6.1-1nodesource.el6.x86_64                        1/1
  Verifying  : 1:nodejs-4.6.1-1nodesource.el6.x86_64                        1/1

Installed:
  nodejs.x86_64 1:4.6.1-1nodesource.el6

Complete!

Step 3 (optinal): install build tools

[root@tutorialspots ~]# yum install gcc-c++ make
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirror.trouble-free.net
 * epel: mirror.us.leaseweb.net
 * extras: mirror.netdepot.com
 * remi: repo1.ash.innoscale.net
 * remi-php55: repo1.ash.innoscale.net
 * remi-php56: repo1.ash.innoscale.net
 * remi-test: repo1.ash.innoscale.net
 * updates: mirrors.tripadvisor.com
Package 1:make-3.81-23.el6.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package gcc-c++.x86_64 0:4.4.7-17.el6 will be installed
--> Processing Dependency: libstdc++-devel = 4.4.7-17.el6 for package: gcc-c++-4
.4.7-17.el6.x86_64
--> Processing Dependency: gcc = 4.4.7-17.el6 for package: gcc-c++-4.4.7-17.el6.
x86_64
--> Processing Dependency: libmpfr.so.1()(64bit) for package: gcc-c++-4.4.7-17.e
l6.x86_64
--> Running transaction check
---> Package gcc.x86_64 0:4.4.7-17.el6 will be installed
--> Processing Dependency: cpp = 4.4.7-17.el6 for package: gcc-4.4.7-17.el6.x86_
64
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc-4.4.7-17.el
6.x86_64
--> Processing Dependency: cloog-ppl >= 0.15 for package: gcc-4.4.7-17.el6.x86_6
4
---> Package libstdc++-devel.x86_64 0:4.4.7-17.el6 will be installed
---> Package mpfr.x86_64 0:2.4.1-6.el6 will be installed
--> Running transaction check
---> Package cloog-ppl.x86_64 0:0.15.7-1.2.el6 will be installed
--> Processing Dependency: libppl_c.so.2()(64bit) for package: cloog-ppl-0.15.7-
1.2.el6.x86_64
--> Processing Dependency: libppl.so.7()(64bit) for package: cloog-ppl-0.15.7-1.
2.el6.x86_64
---> Package cpp.x86_64 0:4.4.7-17.el6 will be installed
---> Package glibc-devel.x86_64 0:2.12-1.192.el6 will be installed
--> Processing Dependency: glibc-headers = 2.12-1.192.el6 for package: glibc-dev
el-2.12-1.192.el6.x86_64
--> Processing Dependency: glibc-headers for package: glibc-devel-2.12-1.192.el6
.x86_64
--> Running transaction check
---> Package glibc-headers.x86_64 0:2.12-1.192.el6 will be installed
--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.
12-1.192.el6.x86_64
--> Processing Dependency: kernel-headers for package: glibc-headers-2.12-1.192.
el6.x86_64
---> Package ppl.x86_64 0:0.10.2-11.el6 will be installed
--> Running transaction check
---> Package kernel-headers.x86_64 0:2.6.32-642.6.2.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package              Arch        Version                    Repository    Size
================================================================================
Installing:
 gcc-c++              x86_64      4.4.7-17.el6               base         4.7 M
Installing for dependencies:
 cloog-ppl            x86_64      0.15.7-1.2.el6             base          93 k
 cpp                  x86_64      4.4.7-17.el6               base         3.7 M
 gcc                  x86_64      4.4.7-17.el6               base          10 M
 glibc-devel          x86_64      2.12-1.192.el6             base         988 k
 glibc-headers        x86_64      2.12-1.192.el6             base         617 k
 kernel-headers       x86_64      2.6.32-642.6.2.el6         updates      4.4 M
 libstdc++-devel      x86_64      4.4.7-17.el6               base         1.6 M
 mpfr                 x86_64      2.4.1-6.el6                base         157 k
 ppl                  x86_64      0.10.2-11.el6              base         1.3 M

Transaction Summary
================================================================================
Install      10 Package(s)

Total download size: 28 M
Installed size: 59 M
Is this ok [y/N]: y
Downloading Packages:
(1/10): cloog-ppl-0.15.7-1.2.el6.x86_64.rpm              |  93 kB     00:00
(2/10): cpp-4.4.7-17.el6.x86_64.rpm                      | 3.7 MB     00:03
(3/10): gcc-4.4.7-17.el6.x86_64.rpm                      |  10 MB     00:02
(4/10): gcc-c++-4.4.7-17.el6.x86_64.rpm                  | 4.7 MB     00:03
(5/10): glibc-devel-2.12-1.192.el6.x86_64.rpm            | 988 kB     00:00
(6/10): glibc-headers-2.12-1.192.el6.x86_64.rpm          | 617 kB     00:00
(7/10): kernel-headers-2.6.32-642.6.2.el6.x86_64.rpm     | 4.4 MB     00:03
(8/10): libstdc++-devel-4.4.7-17.el6.x86_64.rpm          | 1.6 MB     00:04
(9/10): mpfr-2.4.1-6.el6.x86_64.rpm                      | 157 kB     00:00
(10/10): ppl-0.10.2-11.el6.x86_64.rpm                    | 1.3 MB     00:00
--------------------------------------------------------------------------------
Total                                           1.3 MB/s |  28 MB     00:21
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : mpfr-2.4.1-6.el6.x86_64                                     1/10
  Installing : cpp-4.4.7-17.el6.x86_64                                     2/10
  Installing : libstdc++-devel-4.4.7-17.el6.x86_64                         3/10
  Installing : ppl-0.10.2-11.el6.x86_64                                    4/10
  Installing : cloog-ppl-0.15.7-1.2.el6.x86_64                             5/10
  Installing : kernel-headers-2.6.32-642.6.2.el6.x86_64                    6/10
  Installing : glibc-headers-2.12-1.192.el6.x86_64                         7/10
  Installing : glibc-devel-2.12-1.192.el6.x86_64                           8/10
  Installing : gcc-4.4.7-17.el6.x86_64                                     9/10
  Installing : gcc-c++-4.4.7-17.el6.x86_64                                10/10
  Verifying  : glibc-devel-2.12-1.192.el6.x86_64                           1/10
  Verifying  : glibc-headers-2.12-1.192.el6.x86_64                         2/10
  Verifying  : kernel-headers-2.6.32-642.6.2.el6.x86_64                    3/10
  Verifying  : ppl-0.10.2-11.el6.x86_64                                    4/10
  Verifying  : mpfr-2.4.1-6.el6.x86_64                                     5/10
  Verifying  : libstdc++-devel-4.4.7-17.el6.x86_64                         6/10
  Verifying  : gcc-c++-4.4.7-17.el6.x86_64                                 7/10
  Verifying  : gcc-4.4.7-17.el6.x86_64                                     8/10
  Verifying  : cpp-4.4.7-17.el6.x86_64                                     9/10
  Verifying  : cloog-ppl-0.15.7-1.2.el6.x86_64                            10/10

Installed:
  gcc-c++.x86_64 0:4.4.7-17.el6

Dependency Installed:
  cloog-ppl.x86_64 0:0.15.7-1.2.el6
  cpp.x86_64 0:4.4.7-17.el6
  gcc.x86_64 0:4.4.7-17.el6
  glibc-devel.x86_64 0:2.12-1.192.el6
  glibc-headers.x86_64 0:2.12-1.192.el6
  kernel-headers.x86_64 0:2.6.32-642.6.2.el6
  libstdc++-devel.x86_64 0:4.4.7-17.el6
  mpfr.x86_64 0:2.4.1-6.el6
  ppl.x86_64 0:0.10.2-11.el6

Complete!

Now you can check your nodejs version

[root@tutorialspots ~]# node --version
v4.6.1

1 Comment

Leave a Reply