top of page
Writer's pictureSiddhesh Kadam

How to install node.js on Centos using NVM (Node Version Manager)



Node.js is an open source server environment. Node.js allows you to run JavaScript on the server.


There are different method you can use to install and setup node.js on centos operating system.

In this session we are going to see how to intall Node.js using NVM.


To install NVM on Centos machin, visit the project’s GitHub page. You can use below command to download its installer bash script, which will install the nvm script for current logged in user.


[root@siddhesh ~]# curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 13527  100 13527    0     0   6678      0  0:00:02  0:00:02 --:--:--  6680
=> Downloading nvm from git to '/root/.nvm'
=> Cloning into '/root/.nvm'...
remote: Enumerating objects: 290, done.
remote: Counting objects: 100% (290/290), done.
remote: Compressing objects: 100% (257/257), done.
remote: Total 290 (delta 35), reused 97 (delta 20), pack-reused 0
Receiving objects: 100% (290/290), 163.27 KiB | 0 bytes/s, done.
Resolving deltas: 100% (35/35), done.
=> Compressing and cleaning up git repository

=> Appending nvm source string to /root/.bashrc
=> Appending bash_completion source string to /root/.bashrc
=> Close and reopen your terminal to start using nvm or run the following to use it now:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
[root@siddhesh ~]#

Then source current user bash profile to start using installed NVM environment.


[root@siddhesh ~]# source ~/.bash_profile
[root@siddhesh ~]#

Now lets see list of available version of Node.js using NVM.


[root@siddhesh ~]# nvm list-remote
        v0.1.14
        v0.1.15
        v0.1.16
        v0.1.17
        v0.1.18
        v0.1.19
        v0.1.20
        .
        .
        .
       v12.16.0   (LTS: Erbium)
       v12.16.1   (Latest LTS: Erbium)
        v13.0.0
        v13.0.1
        v13.1.0
        v13.2.0
        v13.3.0
        v13.4.0
        v13.5.0
        v13.6.0
        v13.7.0
        v13.8.0
        v13.9.0
       v13.10.0
       v13.10.1
       v13.11.0
       v13.12.0
[root@siddhesh ~]# 

Here, I am going to install Node.js v13.2.0 using nvm


[root@siddhesh ~]# nvm install v13.2.0
Downloading and installing node v13.2.0...
Downloading https://nodejs.org/dist/v13.2.0/node-v13.2.0-linux-x64.tar.xz...
######################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v13.2.0 (npm v6.13.1)
Creating default alias: default -> v13.2.0
[root@siddhesh ~]#

To verify installed version of Node.js and its alias status run below command.


[root@siddhesh ~]# nvm list
->      v13.2.0
         system
default -> v13.2.0
node -> stable (-> v13.2.0) (default)
stable -> 13.2 (-> v13.2.0) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/erbium (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.19.0 (-> N/A)
lts/erbium -> v12.16.1 (-> N/A)
[root@siddhesh ~]# 

Here you can see that (N/A) its release base aliases are not available on the current machin.

To get this install run the following nvm command.


[root@siddhesh ~]# nvm install lts/argon
Downloading and installing node v4.9.1...
Downloading https://nodejs.org/dist/v4.9.1/node-v4.9.1-linux-x64.tar.xz...
######################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v4.9.1 (npm v2.15.11)
[root@siddhesh ~]# nvm install lts/dubnium
 Downloading and installing node v10.19.0...
Downloading https://nodejs.org/dist/v10.19.0/node-v10.19.0-linux-x64.tar.xz...
######################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v10.19.0 (npm v6.13.4)
[root@siddhesh ~]#

Post installation of all its require aliases, nvm list output will look like below.


[root@siddhesh ~]# nvm list
       v0.11.16
    iojs-v3.3.1
         v4.9.1
        v6.17.1
        v8.17.0
       v10.19.0
       v12.16.1
->      v13.2.0
         system
default -> v13.2.0
node -> stable (-> v13.2.0) (default)
stable -> 13.2 (-> v13.2.0) (default)
iojs -> iojs-v3.3 (-> iojs-v3.3.1) (default)
unstable -> 0.11 (-> v0.11.16) (default)
lts/* -> lts/erbium (-> v12.16.1)
lts/argon -> v4.9.1
lts/boron -> v6.17.1
lts/carbon -> v8.17.0
lts/dubnium -> v10.19.0
lts/erbium -> v12.16.1
[root@siddhesh ~]#

You can verify its installation by running following command :


[root@siddhesh ~]# node --version
v13.2.0
[root@siddhesh ~]#

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page