How to Install Node.js with NVM on Linux, Mac and Windows
Node.js is a powerful JavaScript runtime used for building server-side applications, but managing multiple versions can be difficult. NVM (Node Version Manager) makes it easy to install and switch between different Node.js versions.
NVM is a handy tool that allows you to install and switch between different versions of Node.js on your system with ease.
In this guide, we'll show you how to install Node.js with NVM and manage different versions on your system.
Now that we've introduced the stars of the show, let's get started with the installation process.
How To Install NVM on Linux and Mac
To install nvm on Linux and Mac, follow these simple steps:
Open a terminal window and run the following command :
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
If it was successfully installed, the output should be something like this
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
Reload profile config
Run the following command to reload your profile configuration:
source ~/.bashrc
# or
source ~/.bash_profile
# or
source ~/.zshrc
Check NVM Version
Check nvm version to ensure that it is installed on your system.
nvm -v
# 0.39.1
Skip the following section if you are not on Windows
How To Install NVM on Windows
Don't worry ! You can install NVM on Windows and use it, OK ? It's very very easy !
Follow the steps below:
- Go to https://github.com/coreybutler/nvm-windows/releases
- Scroll to Assets section and find the following file and click to download it
nvm-setup.exe
- Open the downloaded file and install it by following the on-screen instructions
That's it!
Now check nvm version to confirm that it has been installed
nvm -v
How To Install Node.js with nvm
To install Node.js with NVM, follow the steps below :
Install Node.js LTS (Long Terms Support)
nvm install --lts
Install Node.js Latest Version
nvm install node
Install Specific Version
nvm install vX.Y.Z
# example
# nvm install v19.0.0
Set default Node.js version with nvm
nvm alias default vX.Y.Z
Use specific Node.js version with nvm
nvm use vX.Y.X
Check List of Node.js Version
nvm ls-remote
NVM Help
nvm -h
Check out on official NVM Github repo for more informations.
In this guide, we've shown you how to install NVM on Linux, MAc and Windows and use it to manage different versions of Nodejs on your machine. With NVM, you can easily switch between different Nodejs versions and experiment with new features without worrying about compatibility issues. So go forth, and may your Nodejs projects be smooth sailing from now on!
By Mahady Manana, Fullstack Javascript Developer
14 February 2023 at 19 h 15
"Skills are honed through the interplay of learning and teaching - one must learn in order to teach, and teach in order to truly learn”. As a passionate Javascript developer, I enjoy sharing my knowledge and skills with others, and regularly publish tutorials on my website and other platforms about the latest Javascript, Typescript, Node.js, React.js, Next.js and more to help others learn and stay up to date with the latest developments trends.