Why I moving from NVM to Volta


Nowadays, when we need to work with multiple apps and products, and each one has its own version of libraries, it is important to make your environment flexible to changes.
At that moment, nvm
becomes a great option to run multiple versions of Node on my machine, but I’m moving between multiple projects some of them with diferents version of node and needs to rememeber to tell nvm use a specific version is a time that i want to save.
Then Volta comes to save my time, Volta make sure my project has the same tools—without interfering with their workflow or needs to tell which enviroment is required.
The most loved feature of Volta is that it automatically switches to the correct Node.js and package manager versions when you cd
into a project directory, without needing a manual command like nvm use 22
.
By using the volta pin
command, we set the Node version for the project, which automatically creates a Volta section in the package.json
. This is used when moving between projects.
Using Volta
First, let's install Volta. Since I'm using Windows, I'll use winget for the installation.
winget install Volta.Volta
After that, you just need to install Node by choosing the LTS version or selecting a specific version like 20.0.0.
Automatic Node Switching
As I mentioned, Volta helps us set the Node version in the package.json by running the volta pin
command. Let's show a demo.
First, I create a new project and use the command volta pin
to set the version to node@20.
mkdir first-genkit
npm init -y
volta pin node@20
success: pinned node@20.19.2 (with npm@10.8.2) in package.json
Next, create another directory and start a new project. In this project, use the Node LTS version and pin it using the volta pin node
command.
mkdir second-genkit
npm init -y
volta pin node
success: pinned node@22.16.0 (with npm@10.9.2) in package.json
Now, when I move between projects, the Node version switches automatically like magic! It also supports switching from npm to yarn.
I switched two months ago and forget nvm use
🤣! give a try it! https://volta.sh/
Happy coding!
Subscribe to my newsletter
Read articles from Dany Paredes directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Dany Paredes
Dany Paredes
I'm passionate about front-end development, specializing in building UI libraries and working with technologies like Angular, NgRx, Accessibility, and micro-frontends. In my free time, I enjoy writing content for the Google Dev Library, This Is Angular Community, Kendo UI, and sharing insights here.