Install Node.js Using NVM

Install Node.js Using NVM

Learn how to install Node.js using NVM (Node Version Manager) on Linux in a few simple steps.

Alex Rodriguez
2024-01-10
2 min read
Table of Contents

To install Node.js using NVM (Node Version Manager) on Linux, follow these steps:

Step 1: Install NVM

  1. Open your terminal.

  2. Run the following command to download and install NVM:

    SH
    curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
    

    🔹 Replace v0.39.7 with the latest NVM version from the NVM GitHub.

  3. Reload your shell configuration to apply changes:

    SH
    source ~/.bashrc  # For Bash users
    source ~/.zshrc   # For Zsh users
    
  4. Verify NVM installation:

    SH
    nvm --version
    

    If NVM is installed correctly, you’ll see its version number.

Step 2: Install Node.js Using NVM

  1. List available Node.js versions:

    SH
    nvm ls-remote
    
  2. Install the latest stable Node.js version:

    SH
    nvm install --lts
    

    OR, install a specific version (e.g., 20.14.0):

    SH
    nvm install 20.14.0
    
  3. Verify the installation:

    SH
    node -v
    npm -v
    

Step 3: Set Default Node.js Version

If you have multiple Node.js versions, set a default version:

SH
nvm use 20.14.0  # Use specific version
nvm alias default 20.14.0  # Set it as default

Step 4: Check Installed Node.js Versions

List all installed Node.js versions:

SH
nvm ls

Step 5: Uninstall Node.js (If Needed)

To remove a specific Node.js version:

SH
nvm uninstall 20.14.0

Bonus: Install Yarn (Optional)

If you need Yarn (a package manager alternative to npm), install it with:

SH
npm install --global yarn

Verify with:

SH
yarn -v
Share this article:
42 likes
Alex Rodriguez

Alex Rodriguez

JavaScript Instructor

JavaScript expert and former bootcamp instructor. Specializes in making complex concepts simple and engaging for new developers.

Related Articles

Install Docker on Ubuntu
#Docker
#Ubuntu

Install Docker on Ubuntu

Learn how to install Docker on Ubuntu in a few simple steps.

Read More
Install Java on Ubuntu
#Java
#Installation

Install Java on Ubuntu

Learn how to install Java on Ubuntu in a few simple steps.

Read More
Fix Line Ending Issues in VS Code
#VS Code
#Line Endings

Fix Line Ending Issues in VS Code

Learn how to fix CRLF (Carriage Return + Line Feed) and LF (Line Feed) issues in VS Code for consistent line endings in your files.

Read More
Comprehensive Guide to Package Managers in Software Development
#Package Managers
#NPM

Comprehensive Guide to Package Managers in Software Development

A detailed comparison of package managers across different programming languages to help you choose the best one for your development journey.

Read More

Never Miss an Update

Get the latest tutorials, tips, and insights delivered straight to your inbox.

No spam, unsubscribe at any time.