@JS's Notes

Site with notes from my work.

Installing node.js in Linux - Update 1

2020-07-14 System Programing @JS

Update for : Installing Node.js in Linux.

Requirements: user with root privileges or non-root user with sudo privileges.

Repository installation

CentOS and Fedora:

$ curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash -          ## nodejs 14.x
$ curl -sL https://rpm.nodesource.com/setup_12.x | sudo bash -          ## nodejs 12.x
$ curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash -          ## nodejs 10.x

Ubuntu:

$ curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -       ## nodejs 14.x
$ curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -       ## nodejs 12.x
$ curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -       ## nodejs 10.x

Debian:

$ curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -          ## nodejs 14.x
$ curl -sL https://deb.nodesource.com/setup_12.x | sudo bash -          ## nodejs 12.x
$ curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -          ## nodejs 10.x
NodeJS and NPM installation
## Centos and Fedora
## Update and Development Tools installation
$ sudo yum -y update; sudo yum -y groupinstall 'Development Tools'
## OR
$ sudo dnf -y update; sudo dnf -y groupinstall 'Development Tools'

## nodejs installation
$ sudo yum update; sudo yum -y install nodejs
## OR
$ sudo dnf update; sudo dnf -y install nodejs

$ sudo node --version
$ npm --version

## Ubuntu and Debian
$ sudo apt update;
$ sudo apt install -y build-essential
$ sudo apt install -y nodejs
$ node --version
$ npm --version
NVM – Multiple node.js versions in Linux

NVM installation:

$ wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | sudo bash

To download, compile, and install the latest release of node:

$ sudo nvm install node

To install a specific node version, first list the available node versions and then install the version:

$ sudo nvm ls-remote
$ sudo nvm install 11.15.3          ## etc 

You can check all installed version:

$ sudo nvm ls

Reference: Node Version Manager.