How To Install Node.js on Ubuntu 20.04

Опубликовано: 03 Октябрь 2024
на канале: MivoCloud
439
22

Node.js is a JavaScript runtime for server-side programming. It allows developers to create scalable backend functionality using JavaScript, a language many are already familiar with from browser-based web development.

In this guide, we will show you three different ways of getting Node.js installed on an Ubuntu 20.04 server

1. Using apt to install the nodejs package from Ubuntu’s default software repository
2. Using apt with an alternate PPA software repository to install specific versions of the nodejs package
3. Installing NVM, the Node Version Manager, and using it to install and manage multiple versions of Node.js

Useful links
rent VPS/VDS - https://www.mivocloud.com/
NodeSource documentation - https://github.com/nodesource/distrib...

Commands used

FIRST WAY
sudo apt update
sudo apt install nodejs
node - v
sudo apt install npm

SECOND WAY
cd ~
curl - sL https://deb.nodesource.com/setup_16.x -o /tmp/nodesource_setup.sh
nano /tmp/nodesource_setup.sh
sudo bash /tmp/nodesource_setup.sh
sudo apt install nodejs
node - v

THIRD WAY
curl - o - https://raw.githubusercontent.com/nvm...
curl - o - https://raw.githubusercontent.com/nvm... | bash
source ~/.bashrc
nvm list-remote
nvm install vXX.X.X
nvm list
nvm install lts/fermium
nvm use vXX.X.X

UNINSTALL
apt remove nodejs