NVM, short for Node Version Manager, is a handy tool for managing multiple Node.js versions on your Elementary system. With NVM, you can easily switch between different Node.js versions and install packages without interfering with your system’s default configuration. In this article, we will guide you through the process of installing NVM on Elementary OS using Linux commands.

Prerequisites

Before proceeding with the installation, make sure you have a user account with sudo privileges. This will allow you to execute administrative commands required during the installation process.

Step 1: Update System Packages

To begin, let’s update the system packages by running the following command:

sudo apt update

This command will refresh the package lists and ensure that you have the latest versions of all software installed on your system.

Step 2: Install Curl

NVM requires the curl command-line tool to download and install the necessary files. If you don’t have curl installed on your system, you can install it by executing the following command:

sudo apt install curl

This will install curl and its dependencies on your Elementary system.

Step 3: Download and Install NVM

Once curl is installed, you can proceed to download and install NVM. Use the following command to download the installation script:

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

This command will download the installation script from the NVM GitHub repository and execute it using bash. The installation script will take care of setting up NVM on your system.

Step 4: Configure NVM

After the installation is complete, you need to configure NVM by running the following command:

source ~/.bashrc

This command will load the NVM environment variables into your current shell session.

Step 5: Verify the Installation

To verify that NVM has been successfully installed on your Elementary system, you can use the following command:

nvm --version

If NVM is installed correctly, it will display the installed version of NVM.

Step 6: Install Node.js with NVM

Now that NVM is installed, you can use it to install Node.js. To list the available Node.js versions, you can run the following command:

nvm ls-remote

This will display a list of all the available Node.js versions. Choose the version you want to install and execute the following command:

nvm install <version>

Replace <version> with the desired Node.js version number. For example, to install Node.js version 18.16.1, you would run:

nvm install 18.16.1

## install latest node version
nvm install --lts

NVM will download and install the specified Node.js version on your system.

Step 7: Using Node.js

Once the installation is complete, you can start using Node.js. To set a specific Node.js version as the default, you can run the following command:

nvm use <version>

Replace <version> with the desired Node.js version number. For example, to use Node.js version 18.16.1, you would run:

nvm use 18.16.1

This command will set the specified version as the default for your current shell session.

Conclusion

Congratulations! You have successfully installed NVM and Node.js on your Elementary system using Linux commands. Also you can use these commands to install NVM and Node on any Ubuntu based distro. With NVM, you can easily manage different Node.js versions and switch between them as needed. Enjoy developing with Node.js!

LEAVE A REPLY

Please enter your comment!
Please enter your name here