nvm for Node.js: Installation, .nvmrc, and Why It Is a Poor Fit for Servers

nvm makes it easy to keep Node.js 22, 24, and 26 on one laptop and switch between them per project. This guide covers installation, the everyday commands, .nvmrc, what changed in nvm 0.41.0, the problems people usually hit, and why production servers are better off with something else.

Published 10 min read
Colorful JavaScript code on a dark screen

Most developers who work on more than a couple of Node.js projects run into the same thing sooner or later. An old client project still needs Node.js 22, the main product is on 24, and a new project starts on 26, which became LTS at the end of October. A single Node.js from the operating system package manager cannot serve all three, and it is usually older than any of them. nvm, short for Node Version Manager, is the most common answer to that problem. It is also often used in places it was never designed for, especially production servers. This guide covers both sides: how to use nvm well on a development machine, and where it is better to stop using it.

What nvm Actually Does

nvm is a shell script, not a program. Installing it adds a few lines to your shell profile that load a function called nvm every time a terminal opens. Each Node.js version you install is unpacked into its own folder under ~/.nvm/versions/node, and nvm use simply puts the right folder at the front of PATH for the current shell. Nothing is installed system-wide, nothing needs sudo, and a terminal that runs nvm use 22 does not affect another terminal on Node.js 24.

That design explains almost everything about nvm, both the good and the bad. It is simple and safe for a developer working in a terminal. It also means nvm only exists where a shell has loaded your profile, which is exactly the problem once Node.js is started by systemd, cron, or another user.

Installing nvm on Linux, macOS, and WSL

The current release is v0.41.0, published on 4 November 2026. The official way to install it is the install script from the nvm repository. Homebrew also has an nvm formula, but the nvm maintainers do not support that route and ask anyone with a Homebrew-installed nvm to reinstall it with the script before reporting a bug.

  1. 1Make sure curl or wget and git are available. On a fresh Ubuntu or Debian machine that means sudo apt install curl git.
  2. 2Run the install script with the version in the URL: curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | bash. Pinning the version means you know exactly which script you ran. If piping a script straight into bash makes you uneasy, download it first and read it.
  3. 3Close the terminal and open a new one, or reload the profile with source ~/.bashrc or source ~/.zshrc. The script adds two lines that set NVM_DIR and load nvm.sh.
  4. 4Check it with command -v nvm, which should print nvm. The usual which nvm prints nothing, because nvm is a shell function rather than a file on PATH.
  5. 5Install a Node.js version, for example nvm install --lts for the newest LTS line, or nvm install 24 for the latest 24.x. The first version you install becomes the default for new terminals.

Running the same install script again with a newer version in the URL updates nvm in place. Your installed Node.js versions stay where they are.

The Commands You Will Use Every Day

CommandWhat it does
nvm install 24Downloads the latest 24.x, checks its SHA-256 checksum, and switches to it
nvm install --ltsInstalls the newest LTS release, currently 26.13.1
nvm use 22Switches the current terminal to the latest installed 22.x
nvm lsLists installed versions and shows which one is active and which is the default
nvm ls-remote --ltsLists every LTS version available on nodejs.org
nvm alias default 24Sets the version that every new terminal starts with
nvm currentPrints the version active in this terminal
nvm which 24Prints the full path to the node binary for that version
nvm uninstall 20Removes an installed version and its global packages
nvm cache clearDeletes downloaded archives that nvm keeps in its cache

Versions can be written loosely. 24 means the newest installed or available 24.x, 24.22 narrows it to that minor line, and 24.22.3 is exact. There are also aliases: node is the newest release, lts/* is the newest LTS, and lts/krypton points to the 24.x line by its code name.

Pin the Version per Project with .nvmrc

The most useful nvm feature is not a command but a file. Put a file called .nvmrc in the root of the repository containing a single version, for example 24, and commit it. From then on, nvm use or nvm install without an argument reads the file, looking in parent folders as well, and switches to the version the project expects. A new team member clones the repository, runs nvm install, and is on the right Node.js without having to ask anyone.

Whether to write 24 or 24.22.3 is a real choice. A major version only lets each developer pick up security patches without a commit, which suits most application projects. An exact version gives everyone the same binary, which matters for native addons or when you are chasing a bug that appeared between two patch releases, but someone then has to update the file after every security release. In 2026 there have been six of those, so we usually write the major version and pin the exact version only in the Docker image.

.nvmrc is read by much more than nvm. The setup-node action on GitHub Actions accepts node-version-file: .nvmrc, fnm reads it, Netlify reads it, and mise can be configured to. That makes it a good single place to state the version. Add an engines field in package.json, such as "node": ">=24", if you also want npm to warn when someone installs dependencies on the wrong version, and engine-strict=true in .npmrc if that warning should be an error.

nvm does not switch versions automatically when you enter a folder. If you want that, the nvm README has short hooks for bash, zsh, and fish that call nvm use whenever the directory changes. They work, but they run on every cd, so on a slow machine you may notice them.

What Changed in nvm 0.41.0

The timing of this release is not a coincidence. Starting with Node.js 27, the project moves from two major releases a year to one, and each major spends about six months as an alpha before its first stable release. The first Node.js 27 alpha came out at the end of October, and alpha builds are published on nodejs.org next to normal releases. Older nvm versions could treat them as the newest Node.js, so nvm install node might have put an alpha on your machine.

  • Alpha releases are now excluded by default. nvm install node, nvm install 27, and nvm ls-remote ignore them unless you ask with --only=alpha.
  • nvm records the LTS status of every version, so nvm alias default --lts node points to the newest installed LTS rather than the newest version overall.
  • nvm ls-remote marks the version that the node alias would install and the versions your own aliases point to.
  • Several fixes harden the download path, including only caching an archive after its checksum passes and keeping text from a mirror out of shell arithmetic.

If you installed nvm a year or two ago, it is worth updating. Run the install script with v0.41.0 in the URL, and keep your existing versions.

Problems People Usually Hit

  • nvm: command not found after installing. The script added its lines to a profile file your shell does not read, for example ~/.bashrc when your terminal opens a login shell that reads ~/.bash_profile. Copy the two lines to the right file, or set PROFILE to the correct path and run the install script again.
  • Global packages disappear after switching versions. Every Node.js version has its own global node_modules, so a package installed with npm install -g under 22 does not exist under 24. Use nvm install 26 --reinstall-packages-from=24 when you move, or list the packages you always want, one per line, in $NVM_DIR/default-packages.
  • pnpm or Yarn stop working on Node.js 26. Corepack is no longer bundled with Node.js 26, so corepack enable fails. Install pnpm or Corepack explicitly for each version, or add it to default-packages so every new version gets it.
  • The terminal takes noticeably longer to open. Loading nvm.sh adds a delay that people on slower laptops or WSL notice. Loading nvm with --no-use helps, as do lazy loading plugins for zsh. If it still bothers you, that is the main reason to look at fnm.
  • A warning that nvm is not compatible with the npm prefix option. Something set prefix in ~/.npmrc, often an earlier attempt to avoid sudo for global installs. Remove that line, or run nvm use --delete-prefix with the version.
  • Installing an old version takes ages. When nodejs.org has no binary for your platform, for example very old versions on Apple Silicon, nvm compiles from source. Set NVM_NO_SOURCE_FALLBACK=1 if you would rather get an error than a twenty minute build.
  • The disk fills up slowly. Each installed version takes well over a hundred megabytes. Run nvm ls now and then and remove versions no project uses any more.

On Windows, nvm does not run in PowerShell or cmd at all. It works inside WSL, which is what we recommend for Node.js development on Windows anyway, because file watching and native modules behave the same as on the Linux servers the code eventually runs on. nvm-windows is a separate project with a similar name and similar commands, but it works differently: it switches one system-wide link, so nvm use changes the version for every open terminal at once.

Why nvm Causes Trouble on Servers

Plenty of tutorials for deploying Node.js to a VPS start with installing nvm, and it works the first time because the person following them is in an interactive shell. Problems appear later, at moments that are inconvenient by nature, such as a reboot or a security release.

  • systemd and cron do not read .bashrc. A unit file with ExecStart=node server.js fails with node not found, so people paste the full path, such as /home/deploy/.nvm/versions/node/v24.22.2/bin/node. That path still points to the old binary after the next nvm install, and the service keeps running the unpatched version.
  • PM2 saves the PATH it had when pm2 startup ran. After upgrading Node.js, PM2 at boot still uses the old version until someone runs pm2 unstartup, pm2 startup, and pm2 save again.
  • sudo node and other users cannot see it. nvm lives in one user's home folder. Root, another deploy user, or a monitoring agent will either find no Node.js or find a different one from the system packages.
  • It is hard to see what is really running. After a few upgrades a server can have four Node.js versions installed, a default alias pointing to one, and services pinned to others. In our experience this is the most common reason a server stays vulnerable after the team believes it has been patched.

If you have to keep nvm on a server for now, keep the damage small. Use one dedicated user for the application. In systemd, run the app through the nvm-exec script that ships with nvm, for example ExecStart=/home/deploy/.nvm/nvm-exec node server.js with Environment=NODE_VERSION=24, so the unit follows the latest installed 24.x instead of a fixed path. Log process.version when the app starts, so you can check from the logs which version is actually running.

For new servers, choose one of the options below. They all put Node.js in a fixed system path that every user and every service manager can see.

MethodBest forWhat to watch
Docker image such as node:24-bookworm-slimMost new deployments, and any team already building containersRebuild the image after each Node.js security release, or it keeps the old version
NodeSource apt or yum repositoryA VPS that runs one or two apps directly on the hostOne major version per server, and upgrades arrive through apt upgrade
Official binary tarball in /opt with a link in /usr/local/binServers without internet access to a package repositoryUpdates are entirely manual, so they need to be on a checklist
Node.js from the distribution packagesInternal tools where an older version is acceptableOften several majors behind, for example Ubuntu 24.04 ships Node.js 18

nvm Compared with fnm, Volta, mise, and n

ToolHow it worksStatus in November 2026Good fit when
nvmShell script that changes PATH per terminalActively maintained, v0.41.0You want the most widely documented option on Linux, macOS, or WSL
fnmSingle Rust binary, reads .nvmrc and .node-versionMaintained, v1.39.0 from March 2026Shell start-up time matters, or you need native Windows support
VoltaShims that pick the version from package.jsonUnmaintained, the authors recommend moving to miseOnly for existing setups that still work; avoid it for new ones
miseManages Node.js together with Python, Go, Java, and other toolsVery active, releases several times a monthA project uses several languages and you want one tool and one config file
nReplaces the single system Node.js in /usr/localMaintained, simple by designA machine needs one version at a time and you want easy upgrades

For a team, the tool matters less than agreeing on one. If half the team uses nvm and half uses fnm, that is fine as long as both read the same .nvmrc. What causes trouble is a project with .nvmrc, a volta field in package.json, and a .tool-versions file that each name a different version.

What We Recommend

  • On developer machines, use nvm or fnm. Both are fine, and nvm has the most answers when something goes wrong.
  • Commit a .nvmrc with the major version to every Node.js repository, and point CI to the same file instead of writing the version again in the workflow.
  • For new projects, start on Node.js 26, which is the active LTS. Projects on 24 have support until April 2028, and projects on 22 should plan to move before its end of life on 30 April 2027.
  • On production servers, run Node.js from a Docker image or a system package rather than nvm, and make sure the version actually running can be checked from outside.
  • After each Node.js security release, update the version on developer machines too with nvm install 24 or the line you use, so local testing matches production.

nvm is a small tool that solves a real problem well, as long as it stays on the machines where a person types commands. If your team is still deploying Node.js with nvm and wants to move to containers or a cleaner server setup, our cloud and DevOps team can help with the migration, and our DevOps training covers the same practices for teams that want to run it themselves.

Key takeaways

  • nvm is a shell function that installs each Node.js version in your home folder and switches PATH per terminal, with no sudo needed.
  • Install it with the script from the nvm repository, pinned to v0.41.0, and check it with command -v nvm.
  • Commit a .nvmrc with the major version to each project. nvm, fnm, GitHub Actions, and Netlify all read it.
  • nvm 0.41.0 skips Node.js alpha releases by default, which matters now that Node.js 27 is in its alpha phase.
  • Global packages, including pnpm now that Corepack is not bundled with Node.js 26, are separate for each version.
  • On production servers, prefer Docker or a system package. nvm paths, systemd, cron, and PM2 often leave a server on an old version.
Share this article

Related articles

More articles on software development, AI, cloud, and infrastructure.

A rack of servers with status lights in a server roomBackend Development

11 min read

PHP-FPM Explained: Pools, pm.max_children, and Fixing 502 and 504 Errors

Most PHP sites behind Nginx run on PHP-FPM, yet many servers still use the default pool with five workers. This guide explains how PHP-FPM works, how to size pm.max_children from real memory use, how to give each site its own pool and PHP version, and what the common 502 and 504 errors usually mean.

A weathered metal surface with patches of orange rust and fine scratchesBackend Development

10 min read

Rust for Business Software: Where It Pays Off and Where Go or Node.js Is Enough

Rust is now in the Linux kernel, Android, and the core of Cloudflare. That does not mean every business application should be written in it. What Rust actually gives you, a benchmark against Go and Node.js on 2 million rows, where it is worth the learning curve, and how to adopt it without rewriting everything.

Let’s talk

Looking for a software development partner?

Tell us about your project, what you need to build, and the challenges you are facing. We can discuss the technical approach, scope, timeline, and estimated cost.

Start a conversation