How to install node using npm and n module?
Installing Node using npm and n Module
Overview: This article provides step-by-step instructions for installing npm and the n module on Linux distribution, essential for managing Node versions efficiently.
Step 1. Install npm.
- On centos 7
:~# yum install epel-release
:~# yum install npm
- On Ubuntu 16/18 and Debian 10
:~# apt install npm
- On Ubuntu 20/22
:~# apt-get update
:~# apt install npm
Step 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 http://registry.npmjs.org/
:~# npm install -g n
Step 3. Install node by running :
Add insecure to install without SSL:
:~# n --insecure latest
For example: n --insecure 19
- To install the latest version:
:~# n latest
- To install the corresponding version :
:~# n version.number
Ex: :~# 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 :
Related Articles: