Skip to content

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.

Terminal window
brew install mise
mise use -g node@22
mise use -g npm:@antfu/ni
~/.config/mise/config.toml
[tools]
node = "22"
"npm:@antfu/ni" = "latest"
[settings]
idiomatic_version_file_enable_tools = ["node"]

Verify that it is working.

Terminal window
mise doctor

You 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.

Terminal window
mise missing: node@18.20.4
$ mise install

You can install npm tools and have mise manage them across all of your node versions:

Terminal window
mise use -g npm:prettier

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.

Install volta.

Terminal window
curl https://get.volta.sh | bash

Install default versions of node and package managers which are used when there are no package managers.

Terminal window
volta install node@20
volta install yarn@1
volta install pnpm

Inside of a repository, you can pin the node version and package manager to use in the package.json file with the following commands:

Terminal window
volta pin node
volta pin pnpm

If 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.

Install fnm.

Terminal window
curl -fsSL https://fnm.vercel.app/install | bash

Setup fish according to these instructions. Add the --use-on-cd option to the fnm to change node version when you change directories.

~/.config/fish/conf.d/fnm.fish
fnm env --use-on-cd | source

Add the --corepack-enabled option to use corepack to manage package managers like pnpm and yarn.

~/.config/fish/conf.d/fnm.fish
fnm env --use-on-cd --corepack-enabled | source

See other fnm options here.

Add fish auto complete.

Terminal window
touch ~/.config/fish/completions/fnm.fish
fnm completions --shell fish > ~/.config/fish/completions/fnm.fish

Restart your terminal.

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.