How To: Volta (NVM Alternative)

Ever been tempted to smash your laptop from yet another Node version conflict from tooling hell? Volta is for you.

Suppose you have two projects, each requiring their own version of node.

Project 1

cd /path/to/project-using-node-14
node -v

Project 2

cd /path/to/project-using-node-16
node -v

How does Volta work?

Rather than changing your node version system-wide, Volta simply shims the tools you need for each project directory. This feels like a lifesaver if you’re running Apple silicon / m1 chip on a new Macbook. Also, Volta runs FAST. Better yet: Volta ensures even global dependencies respect the requirements of your package.

For example, installing the Typescript package:

npm install --global typescript

Depending on the project you’re in, this executable will switch to the project’s chosen version of TypeScript:

cd /path/to/project-using-typescript-3.9.4
tsc --version # 3.9.4
cd /path/to/project-using-typescript-4.1.5
tsc --version # 4.1.5

You can also specify your tooling within your package.json :

"volta": {  "node": "14.17.0",  "yarn": "1.22.10"}

This allows others to use volta setup without ever having to lookup what version of node the project needs. In other words: once you setup a project, Volta gets tooling out of your way and you don’t have to think about it anymore.

A word about Brew conflicts

Volta handles node , yarn , and global dependencies. If you previously installed any of those tools via brew you will want to brew uninstall them and let Volta handle it to avoid conflicts. This is actually the benefit of using Volta.

Why not use NVM?

It’s not so much that NVM is bad. It’s just that Volta is much better. Enjoy!