Skip to Content

How to install node using npm and n module?

 Install node using npm and n module
1. Install npm
  On centos 7
 root@localhost:~  yum install epel-release
root@localhost:~ yum install npm
On Ubuntu 16/18 and Debian 10

root@localhost:~  apt install npm  

On Ubuntu 20/22

root@localhost:~  apt-get update

root@localhost:~  apt install npm

2. Install n, Node’s version manager:

 If you are not using SSL, you need to set the repo to HTTP by running : 

root@localhost:~ npm config set registry 

root@localhost:~  npm install -g n   

3. Install node by running :

Add insecure to install without SSL: 

root@localhost:~ n --insecure latest

For example:  n --insecure  19

  To install the latest version: 

     root@locallhost:~ n latest

To install the corresponding version :

     root@localhost:~ n version.number

For example,   root@localhost:~   n  19


To switch between multiple node versions you need to run the "n" command select the version using the up/down arrow keys and press Enter : 

root@jumpserver:~#  n