nvm install: Node Version Manager setup and usage
Learn how to install and manage multiple Node.js versions with nvm install. This step-by-step guide covers prerequisites, commands, and troubleshooting for developers using Install Manual as a reference.

To use nvm install effectively, first install NVM itself, then install a Node.js version and switch between versions as needed. Run `nvm install node` to fetch the latest version, or `nvm install 18` for a specific release. Use `nvm use 18` to switch, and `nvm alias default 18` to set a global default.
What is NVM and why use it?
Node Version Manager (NVM) is a script-based tool that lets you install and switch between multiple Node.js versions on the same system. This is crucial for developing and testing against different environments without re-installing Node manually. When you adopt NVM, you avoid the pain of global installations and PATH conflicts across projects. According to Install Manual, NVM reduces version-related issues and simplifies onboarding (Install Manual Analysis, 2026).
Why it matters
- Consistent environments across teammates
- Easy testing of new Node releases
- Lightweight, per-user installation
How it works NVM keeps separate installations in your home directory and rewrites your shell to point node, npm, and other binaries to the selected version.
nvm --versionIf you see a version number, NVM is installed. If not, proceed to install NVM as described in the next section.
Installing NVM
To begin, you install the NVM script via curl or wget. The commands below fetch the latest install script from the official repository and run it in your shell. After installation, you may need to restart your terminal or source your profile. The script configures NVM directories and loads nvm.sh on startup.
# Using curl
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
# Using wget
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bashThe installer updates your shell profile to load NVM automatically. If you prefer to load it in this session, run:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvmTo verify, run command -v nvm or nvm --version. If the command prints nothing, relaunch the terminal or source your profile and try again.
Installing Node.js versions with nvm install
With NVM installed, you can install Node.js versions on demand. The nvm install command accepts a version, a major version, or the special keyword node for the latest stable. You can also install the LTS line with --lts. This flexibility makes it easy to pin projects to specific Node.js versions.
# Install the latest available Node.js
nvm install node
# Install a specific major version (e.g., 18.x)
nvm install 18
# Install the LTS version
nvm install --ltsAfter installation, list installed versions and know which one is active:
nvm ls
nvm currentTip: You can fetch remote versions to see what’s available with nvm ls-remote.
Switching between versions and setting a default
NVM lets you switch active Node.js versions at will, which is essential when testing across projects. Use nvm use <version> to switch, and nvm alias default <version> to keep a default for new shells. You can also inspect the currently active version with nvm current.
# Switch to Node 18.x
nvm use 18
# Set 18 as the default for new shells
nvm alias default 18
# Confirm the current version
nvm currentNote: If you installed multiple Node.js versions, “node” in nvm use node refers to the latest stable across the installed set.
Working with .nvmrc and project pinning
Using a local .nvmrc file lets you pin a project to a specific Node.js version. In your project root, create an .nvmrc file containing a version string (e.g., 18). Running nvm use in the project directory will switch to that version automatically if NVM is loaded in the shell. This makes onboarding and CI consistent.
# Create .nvmrc in the project root
echo "18" > .nvmrc
# Use the version specified by .nvmrc
nvm use
# Verify the active version
node -vCI pipelines can also respect .nvmrc by running nvm use early in the job.
Troubleshooting common issues
NVM is straightforward, but some edge cases require a few steps. If nvm is not found, ensure your shell profile loads nvm.sh (see the install step). You can manually source it in the current session using:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"Other common issues include permission prompts during installation, or PATH conflicts from other Node managers. In those cases, ensure you remove conflicting entries and reload the shell. Finally, always verify with nvm --version and node -v after installation.
Automating with scripts and CI for repeatable environments
Automating Node version management is essential in teams. A simple script can install NVM, load it, install a specific Node version, and configure the default. In CI, run the script at job start to guarantee consistency. The key is to load the nvm.sh script before calling nvm install.
# CI-friendly setup (bash)
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install node
nvm use nodeFor Windows-based pipelines, consider using the nvm-windows project, but keep in mind compatibility differences with POSIX shells. Always pin versions in CI to avoid drift.
Security and best practices
Only install NVM from the official repository. Inspect the install script content if you require extra assurance and avoid running scripts from untrusted sources. Regularly update NVM to receive security patches and new features. Finally, prefer pinned versions in your projects and avoid installing global npm packages that are version-sensitive; rely on per-version toolchains instead.
# Update NVM (re-run install script from official source)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bashRemember, your environment should be reproducible, and version drift is a primary cause of bugs.
Steps
Estimated time: 20-40 minutes
- 1
Prepare your environment
Open a terminal, confirm shell type, and verify you have internet access. Ensure you won’t run as root unnecessarily and that your environment variables can be updated.
Tip: Review your shell startup file (e.g., .bashrc or .zshrc) before installing. - 2
Install NVM
Run the official install script via curl or wget. This sets up the nvm function and NVM_DIR in your home directory.
Tip: If the install script changes your shell profile, restart the terminal to apply changes. - 3
Load NVM in the current session
If the shell doesn’t load nvm automatically, source the script manually in the current session.
Tip: Use a single line to source quickly: `export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"`. - 4
Install Node versions
Use `nvm install node` for the latest, or `nvm install <version>` for a specific release. Consider `nvm install --lts` for LTS versions.
Tip: After installation, run `nvm ls` to confirm the installed versions. - 5
Switch between versions
Use `nvm use <version>` to switch; set default with `nvm alias default <version>`.
Tip: Test with `node -v` after switching to verify the active version. - 6
Pin version to a project
Create an `.nvmrc` with the desired version and run `nvm use` in the project directory.
Tip: CI pipelines can honor `.nvmrc` to ensure consistency. - 7
Verify and maintain security
Regularly verify installations with `nvm --version` and keep the install script updated.
Tip: Only install from the official repository to reduce risk.
Prerequisites
Required
- bash-compatible shell (bash, zsh, or similar)Required
- Required
- basic terminal knowledgeRequired
- Required
Commands
| Action | Command |
|---|---|
| Install NVM scriptUse curl; alternative wget method shown in prerequisites. | curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash |
| Install latest Node.js versionFetches the latest Node.js version compatible with NVM. | nvm install node |
| Install specific Node.js versionReplace 18 with your desired major version. | nvm install 18 |
| Set default Node.js versionMakes version 18 the default in new shells. | nvm alias default 18 |
| List installed/remote versionsInspect current and available versions. | nvm ls && nvm ls-remote |
Got Questions?
What is NVM and why use it?
NVM stands for Node Version Manager. It allows you to install, manage, and switch between multiple Node.js versions on the same machine, avoiding conflicts between projects. This is especially useful for testing across versions and maintaining consistent environments.
NVM lets you run different Node versions on one computer, which is great for testing and consistency.
How do I install NVM on macOS or Linux?
Install NVM by running the official install script from GitHub using curl or wget. After installation, source the nvm.sh script or restart your terminal to load NVM into your shell. Then you can install Node versions using nvm install.
Install NVM from the official script, load it in your shell, and you’re ready to manage Node versions.
Can I use NVM on Windows?
NVM is primarily for Unix-like environments (macOS/Linux). Windows users can use the nvm-windows fork, but it is a separate project with its own commands and caveats. For cross-platform workflows, consider running NVM inside Windows Subsystem for Linux (WSL).
NVM isn’t officially for Windows; use nvm-windows or WSL for Windows workflows.
How do I pin a Node version to a project?
Create a .nvmrc file in the project root containing the desired version (e.g., 18). Run nvm use in the project directory to switch automatically when you load the project. This helps CI and teammates stay aligned.
Put the version in a .nvmrc file and use it to lock the project to that Node version.
What if nvm install isn’t found after installation?
This usually means NVM wasn’t loaded in your current shell. Ensure your profile loads nvm.sh, or manually source it with the provided commands, then reopen the terminal and try again.
If nvm isn’t found, load nvm.sh in your shell or restart the terminal.
Main Points
- Install NVM from the official source
- Use nvm install to fetch versions
- Switch versions with nvm use and pin defaults
- Pin project versions with .nvmrc
- Verify installation with node -v and nvm ls