How To Install NVM on AlmaLinux 10
Managing multiple Node.js versions on your AlmaLinux 10 system becomes effortless with Node Version Manager (NVM). This powerful version management tool allows developers to seamlessly switch between different Node.js releases, test applications across various environments, and maintain project-specific configurations without conflicts. Unlike traditional package manager installations, NVM provides granular control over your Node.js ecosystem while eliminating the need for root privileges when installing or switching versions. Whether you’re building modern web applications, testing compatibility across different runtime environments, or managing diverse development projects, NVM delivers the flexibility and control that professional developers demand.
What is NVM (Node Version Manager)?
Node Version Manager, commonly known as NVM, is a bash script-based version management utility designed specifically for Node.js environments. This open-source tool enables developers to install, manage, and switch between multiple Node.js versions on a single system with simple command-line operations. Unlike the Node Package Manager (NPM), which handles JavaScript packages and dependencies, NVM focuses exclusively on managing the Node.js runtime itself.
The tool originated from the developer community’s need for efficient version control in JavaScript development workflows. NVM creates isolated environments for each Node.js version, storing them in separate directories within the user’s home folder. This architecture prevents version conflicts and allows different projects to utilize different Node.js releases simultaneously.
Developers choose NVM over system-wide installations for several compelling reasons. The tool eliminates permission headaches by operating within user space. Testing backward compatibility becomes straightforward with instant version switching. Development teams can ensure consistent environments across different machines by specifying exact Node.js versions.
Real-world applications include maintaining legacy applications that require older Node.js versions while developing new projects with cutting-edge releases. DevOps professionals use NVM in continuous integration pipelines to validate code against multiple runtime versions. Full-stack developers leverage NVM to match production environments precisely during local development.
Benefits of Using NVM on AlmaLinux 10
NVM transforms Node.js version management into a streamlined, efficient process on AlmaLinux 10. Switching between Node.js versions takes mere seconds with a single command. Testing across multiple runtime environments happens without system-level modifications or complicated uninstall procedures.
Project dependency conflicts vanish when each application can specify its required Node.js version independently. Development workflows accelerate since version-specific npm packages remain isolated and intact. The absence of sudo requirements for version management enhances security and reduces administrative overhead.
Rolling back to previous Node.js versions becomes trivial if compatibility issues emerge. Each installed version maintains its own npm global packages, preventing cross-contamination. Developers gain the freedom to experiment with pre-release versions without jeopardizing stable production environments.
AlmaLinux 10’s RHEL-based architecture complements NVM’s user-centric design perfectly. The combination delivers enterprise-grade stability with developer-friendly flexibility, making it ideal for both individual developers and production server environments.
Prerequisites and System Requirements
Before installing NVM on AlmaLinux 10, ensure your environment meets the following requirements. A fresh or existing AlmaLinux 10 installation serves as the foundation for this setup. Root access or sudo privileges are necessary for updating system packages and installing dependencies.
An active internet connection enables downloading the NVM installation script and subsequent Node.js versions. Basic command-line proficiency helps navigate the terminal environment and execute commands effectively. Your system should have at least 1GB of available RAM and 2GB of free disk space for comfortable operation.
Essential tools include curl or wget for downloading files, git for repository management, and development packages for compiling native add-ons. Terminal access through SSH or direct console connection is required for command execution. If you’re working on a remote server, ensure your SSH session remains stable throughout the installation process.
AlmaLinux 10 users benefit from the distribution’s modern package repositories and up-to-date system libraries. The operating system’s compatibility with RHEL ensures smooth NVM operation without unexpected issues.
Understanding AlmaLinux 10 Compatibility
AlmaLinux 10 represents the latest iteration of this popular Red Hat Enterprise Linux derivative. The distribution employs DNF (Dandified YUM) as its primary package management system, offering enhanced performance and dependency resolution compared to legacy package managers.
The transition from AlmaLinux 9 to version 10 introduces updated system libraries and modernized core components. NVM installation procedures remain largely consistent across versions, though package names and repository configurations may vary slightly. The shell environment in AlmaLinux 10 defaults to bash, which NVM integrates with seamlessly.
NVM’s compatibility with AlmaLinux 10 stems from the platform’s POSIX-compliant shell environment and standard Unix-like filesystem structure. The installation script automatically detects the operating system and configures paths appropriately. Community support for AlmaLinux continues growing, with extensive documentation available for troubleshooting common scenarios.
Step 1: Update Your AlmaLinux 10 System
Updating system packages before installing new software prevents compatibility issues and ensures security patches are current. The DNF package manager handles updates efficiently on AlmaLinux 10.
Execute the comprehensive update command:
sudo dnf update -y && sudo dnf upgrade -y
The dnf update
command refreshes package metadata and upgrades installed software to newer versions. The dnf upgrade
command performs similar functions but handles obsolete packages more aggressively. The -y
flag automatically confirms prompts, streamlining the update process.
System updates typically complete within 5-15 minutes, depending on connection speed and the number of outdated packages. The terminal displays download progress, package installation status, and summary information upon completion. Successful updates show no error messages and conclude with a transaction summary.
Verify the update succeeded by checking system package counts and ensuring no broken dependencies exist. If conflicts arise during updates, resolve them before proceeding with NVM installation. Occasionally, kernel updates require a system reboot to take effect fully.
Step 2: Install Required Dependencies
NVM requires specific system utilities to function correctly. Installing these dependencies beforehand ensures a smooth setup process.
Install essential packages with this command:
sudo dnf install tar curl dnf-plugins-core -y
The tar
utility extracts compressed archive files that NVM downloads. The curl
command-line tool transfers data from URLs, enabling script downloads from GitHub. The dnf-plugins-core
package provides additional functionality for the package manager, including repository management capabilities.
For comprehensive development support, install the Development Tools group:
sudo dnf groupinstall "Development Tools" -y
This command installs gcc, g++, make, and related build tools necessary for compiling native Node.js modules. Projects using native dependencies require these compilers to function properly. The installation occupies approximately 500MB of disk space but proves invaluable for serious development work.
Verify dependency installation by checking version numbers:
curl --version
tar --version
Each command should display version information without errors. These dependencies remain useful beyond NVM, supporting various development and system administration tasks.
Step 3: Download and Install NVM
The official NVM installation script automates the setup process, cloning the repository and configuring your shell environment. This script is maintained by the NVM development team on GitHub and receives regular updates.
Download and execute the installation script using curl:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
Alternatively, wget users can employ this command:
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
The installation script performs several critical operations. It clones the NVM repository to ~/.nvm
in your home directory. The script automatically detects your shell type and modifies the appropriate configuration file. For bash users, it appends initialization code to ~/.bashrc
. The script creates necessary environment variables and sets up bash completion for NVM commands.
Security-conscious users should review the script before execution. Download it separately, inspect the contents, then execute it manually if preferred. The script contains no harmful operations but verification builds good security habits.
Expected output includes download progress, repository cloning messages, and confirmation of configuration file modifications. The script typically completes within 30-60 seconds. Upon completion, instructions appear for activating NVM in your current shell session.
The installation creates a .nvm
directory containing the version manager, cached downloads, and installed Node.js versions. Shell configuration files receive appended code that loads NVM automatically during shell initialization.
Step 4: Configure Shell Environment
Shell environment configuration ensures NVM loads automatically when you open new terminal sessions. The installation script handles this automatically for most users, but manual configuration may be necessary in certain scenarios.
The NVM installation adds these lines to your ~/.bashrc
file:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
The NVM_DIR
variable points to the NVM installation directory. The second line sources the main NVM script if it exists, loading core functionality. The third line enables bash completion, providing tab-completion for NVM commands.
For Zsh users, the configuration goes in ~/.zshrc
instead of ~/.bashrc
. Users of other shells should consult their shell’s documentation for proper configuration file locations.
Activate the configuration immediately without restarting your terminal:
source ~/.bashrc
This command reloads the bash configuration file, making NVM available instantly. Alternatively, close your current terminal and open a fresh session to load the updated environment.
If automatic configuration fails, manually add the required lines to your shell configuration file using a text editor. Ensure no syntax errors exist and the NVM_DIR
path points to the correct directory.
Step 5: Verify NVM Installation
Confirming successful installation prevents frustration later. Verification involves checking the NVM command availability and version information.
Check the installed NVM version:
nvm --version
Successful installation displays a version number like 0.39.7
or newer. The specific version depends on the release available when you ran the installation script.
If you encounter a “command not found” error, the shell environment configuration needs attention. Verify the configuration lines exist in your ~/.bashrc
file. Ensure you’ve sourced the configuration file or opened a new terminal session. Check that the .nvm
directory exists in your home folder.
Display NVM’s help menu to explore available commands:
nvm --help
This command lists all NVM operations with brief descriptions. Familiarizing yourself with available commands accelerates your learning curve and reveals powerful features.
The NVM command structure follows a consistent pattern: nvm <command> [options]
. Most commands are intuitive and self-explanatory. Context-sensitive help appears when you enter partial commands.
Installing Node.js with NVM
With NVM successfully installed, you can now install Node.js versions effortlessly. NVM downloads Node.js directly from official sources, ensuring authenticity and security.
Node.js follows a versioning strategy that includes LTS (Long Term Support) and Current releases. LTS versions receive extended support and security updates, making them ideal for production environments. Current releases incorporate the latest features but have shorter support lifecycles.
List all available Node.js versions:
nvm list-remote
This command displays hundreds of Node.js versions, including historical releases and cutting-edge pre-releases. The output can be lengthy, so pipe it through less
for easier navigation.
Install the latest LTS version:
nvm install --lts
This command identifies the newest LTS release and downloads it automatically. The installation process downloads the Node.js binary, extracts it, and configures npm simultaneously. Typical installation completes within 2-5 minutes depending on connection speed.
Install the latest current version:
nvm install node
The keyword node
always references the newest available version. This proves useful for testing applications against cutting-edge Node.js features.
Install a specific version by number:
nvm install 20.11.0
Precise version numbers ensure consistency across development, staging, and production environments. Use exact versions when deploying applications to prevent unexpected behavior from version mismatches.
Install specific LTS codenames:
nvm install lts/iron
LTS releases receive codenames (Iron, Hydrogen, Gallium, etc.) that provide human-friendly references to version lines.
During installation, NVM downloads the Node.js binary tarball, verifies checksums for integrity, extracts files to the appropriate directory, and sets up symbolic links. NPM installs automatically with Node.js, providing package management capabilities immediately.
Verify Node.js installation:
node --version
npm --version
Both commands should display version numbers confirming successful installation. The Node.js version matches what you requested, while npm version corresponds to the default bundled with that Node.js release.
If downloads fail, check your internet connection and firewall settings. NVM attempts to download from official Node.js mirrors. Persistent failures may indicate network restrictions or DNS issues.
Managing Multiple Node.js Versions
One of NVM’s most powerful features is managing multiple Node.js versions concurrently. Different projects often require different runtime versions for compatibility reasons.
Install several versions for testing and compatibility verification:
nvm install 18.20.0
nvm install 20.11.0
nvm install 21.6.0
Each version installs independently without conflicts. The versions coexist peacefully in separate directories.
List installed versions:
nvm list
The output displays all installed versions with special markers. The ->
symbol indicates the currently active version. The default
alias shows which version activates in new shell sessions. The system
entry appears if Node.js was installed via package managers before NVM.
Switch between versions instantly:
nvm use 18.20.0
Version switching takes effect immediately in the current shell session. Run node --version
to confirm the active version changed. This capability enables testing applications across multiple Node.js versions without system modifications.
Set a default Node.js version for new shells:
nvm alias default 20.11.0
The default version loads automatically when you open new terminal sessions. This eliminates the need to manually activate your preferred version repeatedly.
Create custom aliases for convenience:
nvm alias production 20.11.0
nvm alias development 21.6.0
Aliases provide memorable names for specific versions. Switch versions using aliases instead of numbers: nvm use production
.
Each Node.js version maintains its own npm global packages. Installing a package globally under one version doesn’t affect others. This isolation prevents dependency conflicts but requires reinstalling global tools for each version.
Project-specific version management becomes elegant with .nvmrc
files. Create a text file named .nvmrc
in your project root containing only the version number:
20.11.0
Navigate to the project directory and run:
nvm use
NVM automatically reads the .nvmrc
file and activates the specified version. This mechanism ensures team members and CI/CD pipelines use identical Node.js versions.
Essential NVM Commands Reference
Mastering core NVM commands maximizes productivity and unlocks the tool’s full potential. These commands handle common version management scenarios efficiently.
Install specific version: nvm install 20.11.0
downloads and installs the exact version specified. Use this for matching production environments precisely.
Uninstall version: nvm uninstall 18.20.0
removes the specified version from your system, freeing disk space. Ensure the version isn’t currently active before uninstalling.
Switch active version: nvm use 20.11.0
changes the Node.js version in your current shell session. The change affects only the current terminal window.
Display current version: nvm current
shows which Node.js version is currently active. This helps verify version switches succeeded.
List installed versions: nvm ls
displays all Node.js versions installed on your system with status indicators.
List available remote versions: nvm ls-remote
queries the official Node.js repository for all downloadable versions. Filter output for LTS versions: nvm ls-remote --lts
.
Manage aliases: nvm alias <name> <version>
creates named references to specific versions. View all aliases: nvm alias
.
Show version path: nvm which 20.11.0
displays the filesystem path to the specified Node.js binary. This helps when configuring IDE integrations or debugging path issues.
Run script with specific version: nvm run 20.11.0 app.js
executes a JavaScript file using the specified Node.js version without changing the active version.
Execute command with version: nvm exec 20.11.0 node --version
runs any command in the context of a specific Node.js version.
Combining commands creates powerful workflows. Install a version and immediately set it as default: nvm install 20.11.0 && nvm alias default 20.11.0
. Test across multiple versions with a script: for v in 18 20 21; do nvm use $v && npm test; done
.
Uninstalling Node.js Versions with NVM
Removing unused Node.js versions reclaims disk space and simplifies version management. Each version occupies 50-200MB depending on architecture and included modules.
Check which version is currently active before uninstalling:
nvm current
You cannot uninstall the active version. Switch to a different version first if necessary.
Uninstall a specific version:
nvm uninstall 18.20.0
NVM prompts for confirmation before deletion. The command removes the version directory and all associated npm global packages. The operation completes quickly since it only involves file deletion.
Uninstalling a version doesn’t affect other versions or their npm packages. Projects that require the uninstalled version will need migration to an available version.
To clean cached files and free additional space, manually remove the .nvm/.cache
directory:
rm -rf ~/.nvm/.cache/*
This removes downloaded tarballs that NVM keeps for reinstallation purposes. The cache rebuilds automatically when you install versions.
Setting Up Global NPM Packages
Global npm packages provide command-line tools and utilities accessible system-wide. NVM’s architecture means global packages install per Node.js version rather than system-wide.
Install a global package:
npm install -g pm2
The -g
flag indicates global installation. The package becomes available as a command-line tool. Popular global packages include PM2 for process management, TypeScript compiler, ESLint for code linting, and Nodemon for development auto-reloading.
List globally installed packages:
npm list -g --depth=0
The --depth=0
flag limits output to top-level packages, excluding dependencies. This provides a clean view of installed tools.
When switching Node.js versions, global packages don’t transfer automatically. You must reinstall them for each version or use migration strategies. Document essential global packages in your project README for team consistency.
Some developers create shell scripts to reinstall global packages automatically across versions. This automation reduces setup time when installing new Node.js releases.
Troubleshooting Common Issues
Even straightforward installations occasionally encounter problems. Understanding common issues and solutions accelerates troubleshooting.
“nvm: command not found” Error
This indicates shell environment configuration issues. First, verify the .nvm
directory exists in your home folder. Check that configuration lines exist in ~/.bashrc
. Source the configuration file with source ~/.bashrc
or open a new terminal. If problems persist, manually add the NVM initialization code to your shell configuration file.
Permission Denied Errors
NVM should never require sudo for version management. If you encounter permission errors, check file ownership in the .nvm
directory: ls -la ~/.nvm
. Correct ownership if necessary: sudo chown -R $USER:$USER ~/.nvm
.
Installation Script Failures
Network connectivity problems often cause script download failures. Verify internet access and try alternative download methods (curl vs wget). GitHub access restrictions in corporate environments may block the repository. Download the script manually and execute it locally as a workaround.
Node.js Download Failures
Checksum mismatches indicate corrupted downloads. Clear the NVM cache and retry: rm -rf ~/.nvm/.cache/*
. If specific versions consistently fail, try different versions or wait before retrying. Temporary mirror issues resolve themselves quickly.
Version Switching Not Working
Ensure no Node.js processes are running during version switches. Close IDEs and development servers that might lock the Node.js binary. Restart your terminal session to clear environment variables. Verify the desired version is actually installed with nvm ls
.
Conflicts with System-Installed Node.js
NVM conflicts with system-wide Node.js installations. Remove system packages: sudo dnf remove nodejs npm
. Let NVM manage all Node.js installations for consistency.
Repository Conflicts
AlmaLinux repositories sometimes include Node.js packages. Disable conflicting repositories or ensure NVM takes precedence in your PATH variable.
.nvmrc File Issues
Ensure the .nvmrc
file contains only the version number with no extra whitespace or characters. Use Unix line endings (LF) rather than Windows (CRLF). The version specified must be installed on your system.
Corrupted Installation Recovery
Completely remove NVM and reinstall from scratch. Delete the .nvm
directory: rm -rf ~/.nvm
. Remove configuration lines from shell files. Re-run the installation script.
Community support exists through GitHub issues, Stack Overflow, and Node.js forums. Search existing issues before posting new questions, as common problems have documented solutions.
Best Practices for Using NVM on AlmaLinux 10
Adopting best practices maximizes NVM’s benefits and prevents common pitfalls. These guidelines emerge from community experience and production deployments.
Always use LTS versions for production environments. Current releases are suitable for experimentation and learning but lack the stability guarantees of LTS. Production systems demand reliability over cutting-edge features.
Keep NVM updated to access bug fixes and new features. Update by re-running the installation script:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
The script detects existing installations and performs upgrades gracefully.
Use .nvmrc
files in all project repositories. Commit these files to version control so team members and deployment systems use identical Node.js versions. Document the chosen version in README files for transparency.
Document Node.js version requirements in project documentation. Explain why specific versions are necessary and any compatibility considerations. This information helps onboarding new developers and troubleshooting deployment issues.
Regularly clean unused Node.js versions. Accumulating versions wastes disk space without benefit. Audit installed versions monthly and remove obsolete releases.
Review installation scripts before execution. While the official NVM script is trustworthy, verifying contents builds good security habits. Inspect for unexpected commands or suspicious network calls.
Back up critical development environments before major version changes. While NVM version switching is reliable, backups protect against unexpected issues during Node.js upgrades.
Integrate NVM into development workflows seamlessly. Configure IDEs to recognize NVM-managed Node.js installations. Set up pre-commit hooks to verify correct Node.js versions. Include version checks in project startup scripts.
Use NVM in CI/CD pipelines for testing consistency. Install NVM in build environments and use .nvmrc
files to ensure identical versions across local development, testing, and production.
Optimize performance by choosing appropriate Node.js versions for your workload. Newer versions often include performance improvements, but ensure compatibility testing before upgrading production systems.
Avoid common pitfalls like mixing system Node.js with NVM-managed versions. Choose one approach and stick with it consistently. Don’t use sudo with NVM commands, as this creates permission conflicts. Remember that global packages install per-version, requiring reinstallation when switching.
Updating NVM to Latest Version
Maintaining current NVM versions ensures access to bug fixes, new features, and improved Node.js version support. Updates follow the same process as initial installation.
The simplest update method re-runs the installation script:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
The script detects your existing installation and updates it in place. Configuration files remain unchanged unless new features require additional settings.
Alternatively, update manually via Git within the NVM directory:
cd ~/.nvm
git fetch --tags
git checkout $(git describe --abbrev=0 --tags --match "v[0-9]*" origin)
This approach provides more control but requires Git knowledge.
After updating, verify the new version:
nvm --version
Check release notes on the NVM GitHub repository for breaking changes or new features. Major updates occasionally require configuration adjustments.
Backward compatibility is excellent in NVM. Updates rarely break existing installations or version management workflows. Existing Node.js versions remain functional after NVM updates.
Uninstalling NVM Completely
Situations occasionally arise requiring complete NVM removal. Perhaps you’re switching to system package management or troubleshooting persistent issues.
Remove the NVM directory and all installed Node.js versions:
rm -rf ~/.nvm
This deletes NVM itself and all managed Node.js installations. The operation is irreversible, so ensure you have backups of important data.
Remove NVM initialization code from shell configuration files. Edit ~/.bashrc
and delete these lines:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
Clean up cached files that might persist:
rm -rf ~/.npm
rm -rf ~/.nvm
Remove environment variables from your current shell:
unset NVM_DIR
Reload your shell configuration:
source ~/.bashrc
Verify complete removal by attempting to run NVM commands. They should return “command not found” errors.
If you switch to system-managed Node.js after removing NVM, install it via DNF:
sudo dnf install nodejs npm
Reinstalling NVM later follows the standard installation process. No special cleanup is necessary before reinstallation.
Congratulations! You have successfully installed NVM. Thanks for using this tutorial to install the latest version of NVM (Node Version Manager) on ALmaLinux OS 10 system. For additional help or useful information, we recommend you check the official NVM website.