Node Version Manager (NVM) is an excellent tool for developers who need to work with multiple versions of Node.js on a single machine. It allows you to seamlessly switch between Node.js versions, ensuring your development environment is always aligned with your project requirements.
In this guide, we’ll show you how to install and use NVM on Ubuntu 24.04. If you’re looking for a reliable cloud server to get started, check out Hostomy Cloud Servers.
NVM offers several advantages:
Before installing NVM, ensure your system is up-to-date:
sudo apt update && sudo apt upgrade -y
NVM requires curl
and build-essential
. Install them using:
sudo apt install curl build-essential -y
Use the official NVM installation script to install NVM:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
Note: Replace v0.40.1
with the latest version from the NVM GitHub repository.
After installation, load NVM into your current shell session:
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
To make this persistent across sessions, add the following lines to your ~/.bashrc
or ~/.zshrc
file:
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
Then reload your shell:
source ~/.bashrc
Check if NVM is installed correctly:
nvm --version
If you see the version number, NVM is successfully installed!
nvm install node
Replace x.x.x
with the desired version:
nvm install x.x.x
nvm alias default x.x.x
nvm use x.x.x
nvm list
Since each Node.js version has its isolated npm
environment, you can install project-specific dependencies without interference.
For smooth development, deploy your project on a high-performance Hostomy Cloud Server. Enjoy:
NVM simplifies managing Node.js versions, especially when working on multiple projects with varying requirements. Follow this guide to install NVM on Ubuntu 24.04, and you’ll be up and running in no time.
For a seamless experience, pair your development environment with a Hostomy Cloud Server today! 🚀