Feb 13, 2024
2 mins read
Ubuntu users often work on various Node.js projects, each requiring a specific version. This guide will walk you through the process of managing Node.js versions effortlessly on Ubuntu using Node Version Manager (NVM).
Prerequisites: Before proceeding, make sure you have NVM installed. If not, you can install it by running:
|
|
Restart your terminal or run source ~/.bashrc
(or ~/.zshrc
if you’re using Zsh) after installation.
Use the following command to list the available Node.js versions:
|
|
Select the version you want to switch to.
Install the desired Node.js version using the following command:
|
|
Replace <version>
with the version you’ve chosen.
To switch between installed Node.js versions, use:
|
|
This command sets the specified version as the active one.
If you wish to set a specific version as the default for new shells, use:
|
|
Replace <version>
with your preferred default version.
Verify that the switch was successful by checking the current Node.js version:
|
|
This should display the version you set.
NVM simplifies the management of Node.js versions. You can list installed versions with:
|
|
And remove an installed version with:
|
|
Effectively managing Node.js versions on Ubuntu is crucial for project compatibility. Node Version Manager (NVM) streamlines this process, enabling you to effortlessly switch between Node.js versions.
Sharing is caring!