In this article we are going to learn How to install node.js on Ubuntu 22.04 LTS and and any other cloud platform like Azure, EC2, Compute Engine, How to Uninstall Node.js from Ubuntu 22.04 LTS.
Table of Contents
What is Node.js ?
NPM(Node Package Manager) is command line tool for Node.js packages that installs, updates and uninstall packages in your projects.We don’t have install npm separately it is includes with Node.js installation.
- Ubuntu 22.04 LTS
- SSH access with sudo privileges
- Firewall Port: 3000
How to Install Node.js on Ubuntu 22.04 LTS
There are 3 different ways installation of node.js on Ubuntu 22.04 LTS.
- Installation of Node.js on Ubuntu 22.04 LTS from default repository
- Installing Node.js and npm on Ubuntu 22.04 LTS from NodeSource
- Installation of Nodejs on Ubuntu 22.04 LTS using Node version manager
#1:Installation of Node.js on Ubuntu 22.04 LTS from default repository
Before installing,Lets update and upgrade System Packages
sudo apt update
Use below command to install Node.js on Ubuntu 22.04 LTS
sudo apt install nodejs
Once your installation done, verify the installation of node.js using below command,
In most cases, you’ll also want to install npm, the Node.js package manager. You can do this by installing the npm package with apt
sudo apt install npm
After npm installation complete you can verify npm
#2:Installing Node.js and npm on Ubuntu 22.04 LTS from NodeSource
Firstly you have to install curl using below command
sudo apt install curl
Download and run the Node.js installation script, Visit the official node.js page to download current and LTS version.
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
You can now install the Node.js package in the same way you did in the previous section:
sudo apt install nodejs
Verify that the Node.js and npm version on Ubuntu 22.04 LTS
#3:Installation of Nodejs on Ubuntu 22.04 LTS using Node version manager
Another way of installing Node.js that is particularly flexible is to use nvm, the Node Version Manager. NVM is a script that allows you to manage multiple version of Node.js.
Firstly, you need to download and install NVM using wget
sudo apt-get install wget
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.39.0/install.sh | bash
Allow the NVM script to run from your user’s bash profile
verify the NVM version on Ubuntu 22.04 LTS
You can list all Node.js version that can be installed with NVM using
Install the latest stable version of Node.js
nvm install node version(like
You can outlook the different versions you have installed by listing them
You can switch between installed versions
nvm use v18.15.0
Once the installation is completed, verify the Node.js version.
How to Uninstall Node.js from Ubuntu 22.04 LTS ?
Remove node.js using following command
sudo apt remove nodejs
Remove using NVM
Firstly, you have to check recent active version using
Now deactivate the nvm version using below command
In this Article we have covered How to install node.js on Ubuntu 22.04 LTS.
In this article, We have performed ,How to Install Node.js on Ubuntu 22.04 LTS, Checked Node.js and NPM version and performed to uninstall node.js and NPM from ubuntu 22.04 LTS.