Node version manager
Why
When working on multiple front-end application you might get in the situation where you need multiple node versions in order to run those applications. Manually installing and uninstalling node is a time wasting task so another option should be available.
Options?
A well known version manager is nvm, unfortunately it has some drawbacks like:
- Admin permissions are required to change version (prompts are shown)
- Installing & using node versions requires exact version numbers (
nvm use 16
does not work when you would like to use the latest version 16) - Auto swapping node versions based on the folder you are in is not supported
- Global installed packages need to be re-installed after swapping versions
Volta has solved many of these issues and is available on windows & Unix (inc mac). That is why this is our primary choice when it comes to node version management.
Installation
WARNING
Before installing Volta, make sure you uninstall node and nvm when installed
Follow the installation instruction
Usage
Once the installation has finished you can start using Volta
Install node version
volta install node@22
Or
volta install node@22.14.0
More information about managing your toolchain can be found here
Add project config
In order to let Volta know what version your application requires you can use the following command in your projects root:
volta pin node@22
This will add the required Volta config to you package.json
and lets Volta know what version he needs to use in that directory:
"volta": {
"node": "22.14.0",
}
More details can be found in the docs here