Node Version Manager (NVM) is an invaluable tool for any developer working with Node.js, allowing you to install multiple versions of Node.js and switch between them with ease. This flexibility is crucial for testing applications across different versions or managing various projects with different Node.js version requirements. In this guide, we’ll walk you through the process of installing NVM on a Fedora system, setting you up for efficient Node.js version management.
Prerequisites
Before we begin, ensure you have the following:
- A Fedora-based system with terminal access.
- Basic knowledge of terminal commands.
- Sudo or root access for installing packages.
Step 1: Installing Required Dependencies
First, update your system’s package index to ensure you have the latest versions of all packages and their dependencies:
sudo dnf update
Next, install the build essentials and curl, which are necessary for NVM installation and use:
sudo dnf install curl
Step 2: Installing NVM
The best way to install NVM is by using the install script from the NVM GitHub repository. You can do this by running the following command in your terminal:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
Note: Be sure to check the NVM GitHub page for the latest version.
This command downloads and runs the install script. The script clones the NVM repository to ~/.nvm and adds the necessary script to your profile (~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc) so that it’s automatically sourced upon login.
Step 3: Sourcing NVM
To start using NVM right away without restarting your terminal, source the NVM script:
source ~/.bash_profile
# Or the relevant profile file for your shell
Step 4: Verifying NVM Installation
To ensure NVM was installed successfully, you can check the version:
nvm --version
You should see the version number of NVM if the installation was successful.
Step 5: Installing Node.js
With NVM installed, you can now install Node.js. To install the latest version, use:
nvm install node
For installing a specific version of Node.js, you can specify the version number:
nvm install 20.11.0
# Replace with your desired version
Step 6: Using NVM to Manage Node.js Versions
To switch between installed Node.js versions, use:
nvm use 20.11.0
# Replace with the version you wish to use
You can list all installed Node.js versions and see which version you’re currently using with:
nvm ls
Conclusion
Congratulations! You’ve successfully installed NVM on Fedora, opening up a world of flexibility for managing Node.js versions. NVM’s simplicity and versatility make it a must-have tool for Node.js developers, allowing you to focus on development rather than managing software versions.
Remember, you can always run nvm help to see a list of available commands and options to further explore NVM’s capabilities. Happy coding!