Skip to content

Latest commit

 

History

History
95 lines (72 loc) · 2.24 KB

File metadata and controls

95 lines (72 loc) · 2.24 KB

Install Node.js on Ubuntu using NVM and NPM

Welcome! This guide will help beginners install the latest version of Node.js on Ubuntu using NVM (Node Version Manager) and NPM (Node Package Manager). Follow the steps below to get started. 🚀


Prerequisites

  1. A machine running Ubuntu.
  2. Basic knowledge of using the terminal.

Step 1: Update and Upgrade Ubuntu

Before we begin, update your system packages to ensure compatibility. 🛠️

sudo apt update && sudo apt upgrade -y

Step 2: Install Curl

Curl is needed to download the NVM installation script. 📥

sudo apt install curl -y

Step 3: Install NVM (Node Version Manager)

NVM makes it easy to install and manage Node.js versions. Run the following command to install NVM:

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

Verify NVM Installation

Close and reopen your terminal, or run:

source ~/.bashrc

Then check if NVM is installed:

nvm --version

If you see a version number, NVM is successfully installed! 🎉


Step 4: Install the Latest Node.js Version

Now that NVM is installed, use it to install Node.js:

nvm install node

This will install the latest version of Node.js. 🚀

Verify Node.js Installation

Check the installed Node.js version:

node --version

Step 5: Verify NPM Installation

NPM comes bundled with Node.js. Check its version to confirm:

npm --version

Step 6: Set Default Node.js Version (Optional)

To make the latest Node.js version the default for new terminal sessions:

nvm alias default node

Troubleshooting

  • If you face issues, make sure your terminal is reloaded by running:
    source ~/.bashrc
  • For permissions errors, use sudo where needed. ❗

Additional Resources

Happy coding! 🚀