Managing node and package manager versions
mise is a new up and coming “everything” version manager? See this nice breakdown on the differences between mise and volta.
Installation
Section titled “Installation”brew install misemise use -g node@22mise use -g npm:@antfu/ni[tools]node = "22""npm:@antfu/ni" = "latest"
[settings]idiomatic_version_file_enable_tools = ["node"]Verify that it is working.
mise doctorYou don’t need to add mise to the PATH because it adds itself to the PATH.
mise can read the required node version from .nvmrc and .node-version with the idiomatic_version_file_enable_tools setting.
mise missing: node@18.20.4$ mise installYou can install npm tools and have mise manage them across all of your node versions:
mise use -g npm:prettierAlternatives
Section titled “Alternatives”Manage the node and package manager versions by using volta. Volta also allows you to standardise the versions of node and the package managers used in a repository with volta’s config.
Great if you can enforce using volta across all of the codebases you work in or you can consistently rely on a default version of node. Not great if you need to use the version of node specified in a .nvmrc file.
Installation
Section titled “Installation”Install volta.
curl https://get.volta.sh | bashInstall default versions of node and package managers which are used when there are no package managers.
volta install node@20volta install yarn@1volta install pnpmInside of a repository, you can pin the node version and package manager to use in the package.json file with the following commands:
volta pin nodevolta pin pnpmIf you need to use the version of node specified in a .nvmrc or .node-version file, use fnm, a node version manager built in Rust. One of the key selling points is that it can change the version of node when you change directories.
Installation
Section titled “Installation”Install fnm.
curl -fsSL https://fnm.vercel.app/install | bashSetup fish according to these instructions. Add the --use-on-cd option to the fnm to change node version when you change directories.
fnm env --use-on-cd | sourceAdd the --corepack-enabled option to use corepack to manage package managers like pnpm and yarn.
fnm env --use-on-cd --corepack-enabled | sourceSee other fnm options here.
Add fish auto complete.
touch ~/.config/fish/completions/fnm.fishfnm completions --shell fish > ~/.config/fish/completions/fnm.fishRestart your terminal.
nvm.fish
Section titled “nvm.fish”nvm.fish is another performant node version manager written in Fish that respects .nvmrc and .node-version files. Unfortunately, it does not have native support for changing the node version when changing directories.
Take a look at this comment to see a DIY implementation of changing the node version when changing directories. I ran into issues with modifying the script to also install the node version if it wasn’t already installed and jumped ship to fnm.