I’ve switched from nvm to Volta - Why?


I've been using NVM as my Node version manager for quite a long time to manage the different Node versions on my machine. NVM immediately reminds me of the time when I was using RVM (Ruby Version Manager).
Apart from a great name and massive usage,nvm has some issues that can be easily fixed with a “more modern” alternative.
I’ve recently started using Volta and it does have many advantages in comparison with nvm.
First of all, it's really fast (Volta, written in Rust, claims to be ~40x faster than NVM). Switching to different versions or installing new Node/NPM versions has been a real pleasure. The startup time and project version switching are considerably fast.
Second, it always loads the correct Node version you need between your projects, whereas nvm doesn't do it by default. With nvm, each time you switch to a different project that runs a different Node version than the default one, you need to do this either by running nvm use <NODE_VERSION_NUMBER>
or by locking a node version in a .nvmrc
file for each of your projects. Furthermore, you will still need to have a script loaded in your bash profile terminal that automatically searches for a .nvmrc
and updates the node version when needed. In addition, there is always a delay when switching to another version with nvm (Volta switches the Node version instantly).
Volta (and a few others such as pnpm
that can also be used as a NodeJS version manager) handle this under the hood. This way, when you are dealing with multiple repositories using different Node versions, you won't have any bad surprises like updating some dependencies with the wrong Node version, for instance.
For instance, volta pin node@14
will store your pinned version in your package.json
of your project.
"volta": {
"node": "14.21.2"
}
Each time you go to one of your projects, Volta will read your package.json
file and automatically and instantly set the relevant NodeJS version that reflects with what was pinned. You can also (and very easily) install a specific Node version with the following through Volta volta install node@16
.
Volta also allows you to install and pin globally your favorite package manager. e.g. volta install yarn && volta pin yarn@3
for Yarn berry v3.
package.json
...
"volta": {
"node": "18.17.1",
"yarn": "3.6.1"
}
...
It's also good to mention that Volta supports the same .nvmrc
config file as nvm.
Global libraries
With Volta, the packages installed globally on your machine are associated with the correct Node version that installed them, so we are sure we use the stable packages that work on the current running Node version.
Windows support
Finally, although you might not need this, it’s nice to mention that Volta is also available on Windows, whereas nvm is only available on Mac/Linux machines.
Subscribe to my newsletter
Read articles from Pierre-Henry Soria directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Pierre-Henry Soria
Pierre-Henry Soria
I'm Pierre-Henry Soria. A passionate full stack engineer, building things that matter, making a real impact on the world. Really like to take care of others and manage my workflow based on productivity methodologies. Open to fast-paced changes with rapidly evolving business and technologies. I'm always thirsty to learn and undertake new exciting things and thrilling challenges.