How to install NVM (Node Version Manager) on Linux

NVM (Node Version Manager) is a tool that allows you to easily install and manage multiple versions of Node.js on your Linux system. Here’s a step-by-step guide to installing NVM on Linux:

1. Open a Terminal:

    You can open a terminal using the system menu or by using a keyboard shortcut like Ctrl + Alt + T.

    2. Download NVM:

      You can use curl or wget to download the NVM installation script. Below are commands for both options. Choose the one you prefer.

      The version number in the URL (v0.39.1) might change over time, so make sure to check the NVM GitHub repository for the latest release.

      3. Run the NVM Setup Script:

      After downloading the script, run it to set up NVM.

      4. Close and Reopen the Terminal:

      Close the current terminal and open a new one. Alternatively, you can use the following command to apply the changes to the current session:

      If you’re using a different shell (e.g., Zsh), you might need to modify the corresponding configuration file (e.g., ~/.zshrc) instead.

      5. Verify NVM Installation:

      To verify that NVM has been installed successfully, you can run the following command:

      This should display the version number of NVM, confirming that it’s installed.

      6. Install Node.js using NVM:

      Now that NVM is installed, you can use it to install Node.js. To install the latest LTS (Long Term Support) version, you can use the following command:

      You can also install a specific version by replacing --lts with the version number, like nvm install 14.17.5.

      7. Set Default Node.js Version (Optional):

      If you want to set a default Node.js version, you can use the following command:

      Replace <version> with the desired Node.js version, like nvm alias default 14.17.5.

      That’s it! You now have NVM installed on your Linux system, and you can easily manage multiple Node.js versions.


      Posted

      in

      by

      Tags: