Published on

Automatically Switch Node.js Versions with Volta


If you're working on multiple projects then chances are you might be working on different versions with it's dependencies, especially for legacy codebase which does not support the latest version of Node.js (👋, Day job)

Keeping track of it and switching between them is a tedious job. That's where Volta comes in.

What's Volta?

It's a tool to help you manage multiple versions of Node.js and its dependencies and the best part is once we've configured (pinned the version) in the project, then it'll automatically take care of the rest.

Whenever we use that particular project it'll make sure to use the same version which got pinned.

Dependency Volta

Volta is available in all the major OS. We can install it by running the following command

curl | bash

When we run it, it'll setup a new directory $HOME/.volta and configure it to your $PATH.

Make sure to open new tab so that volta command works in your terminal.

Using Volta

Install particular version of Node.js

volta install node@18

Configuring/Pinning the current version of Node.js for your project

volta pin node@18

Once you've pinned your dependencies then volta will make sure to use it whenever we use the project. (Automatically, like magic 🪄)

Happy managing dependencies!