How To Install Node.js on Ubuntu 22.4

  1. First, update your package manager’s package list by running the following command:
sudo apt update

2. Next, install some dependencies that are required to build and run Node.js:

sudo apt install build-essential libssl-dev

3. NVM is written in Bash, so you will need to install the Bash shell if it is not already installed on your system:

sudo apt install bash

4. With the dependencies installed, you can now download and install NVM by running the following command:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

This will download and run the NVM installation script, which will install NVM and add the necessary lines to your Bash profile to enable NVM.

5. Once the installation is complete, you can verify that NVM is installed by running the following command:

   command -v nvm

This should print the path to the nvm executable if it is installed.

6. To start using NVM, you will need to close and reopen your terminal window or run the following command to reload your Bash profile:

 source ~/.bashrc

With NVM installed, you can now use it to install and manage multiple versions of Node.js on your system. For example, to install the latest LTS version of Node.js, you can run the following command:

nvm install --lts

Comments