DEV Community

Cover image for The Ultimate Guide to Node.js Version Managers: NVM, NVS, fnm, Volta, and asdf | Part 2
Erik Harutyunyan
Erik Harutyunyan

Posted on

The Ultimate Guide to Node.js Version Managers: NVM, NVS, fnm, Volta, and asdf | Part 2

NVS (Node Version Switcher)

NVS is a handy, cross-platform utility for managing Node.js versions and their forks. It's written in JavaScript.

How to Install and Use

Installation on macOS and Linux:

  1. Setting the installation path:
export NVS_HOME="$HOME/.nvs"
Enter fullscreen mode Exit fullscreen mode
  1. Clone the repository and install:
git clone https://github.com/jasongin/nvs "$NVS_HOME"
. "$NVS_HOME/nvs.sh" install
Enter fullscreen mode Exit fullscreen mode

This adds NVS into the shell, making it ready for use.

Installation for Windows:

  • You can install using the MSI installer from GitHub.
  • You can also install via the winget command:
winget install jasongin.nvs
Enter fullscreen mode Exit fullscreen mode
  • Or with Chocolatey:
choco install nvs
Enter fullscreen mode Exit fullscreen mode

Using NVS:

  • Install the latest or LTS version of Node.js:** nvs add latest or nvs add lts
  • Install a specific version: nvs add 14.17.0 or nvs add 14
  • Remove versions: nvs rm 14.17.0 or nvs rm 14
  • View installed versions: nvs ls
  • View available versions for installation: nvs ls-remote
  • Switch to a specific Node.js version: nvs use 14
  • Set the default version: nvs link 20
  • Remove the default version link: nvs unlink 20
  • Enable automatic version switching based on the directory:** nvs auto on

This command enables NVS to automatically switch Node.js versions when entering directories containing .node-version or .nvmrc files.

Interactive NVS Menu:

When executed without parameters, NVS opens an interactive menu for switching and downloading Node.js versions.

Image description

Advantages of NVS:

  • Cross-platform: Works on Windows, macOS, and Linux.
  • Ease of use: Interactive menu for quick version management.
  • Automatic switching: Automatically selects the Node.js version based on the current directory.
  • Flexibility: Supports multiple remote sources and version aliases.
  • CI Support: Integration with CI environments like AppVeyor and Travis CI.

Disadvantages of NVS:

  • Node.js dependency: Requires Node.js to be installed to work.
  • Limited support in Windows Command Prompt: Automatic version switching is only supported in PowerShell and Bash.
  • Lower popularity: Smaller community and fewer resources for support compared to more well-known tools.
  • Limited interaction with system package managers: NVS does not integrate with system package managers like APT or Homebrew, which may limit its use in corporate or specialized environments.

fnm (Fast Node Manager)

fnm is one of the newest tools for managing Node.js versions, supporting caching and multithreading, making it significantly faster and more efficient. Written in Rust, fnm provides fast switching between Node.js versions and supports most operating systems.

How to Install and Use

Installation on macOS and Linux:

  • Script:
curl -fsSL https://fnm.vercel.app/install | bash
Enter fullscreen mode Exit fullscreen mode
  • Homebrew:
brew install fnm
Enter fullscreen mode Exit fullscreen mode

Installation for Windows:

  • Winget:
winget install Schniz.fnm
Enter fullscreen mode Exit fullscreen mode
  • Scoop:
scoop install fnm
Enter fullscreen mode Exit fullscreen mode
  • Chocolatey:
choco install fnm
Enter fullscreen mode Exit fullscreen mode

Shell Configuration:

  • Bash: Add to the .bashrc file:
eval "$(fnm env --use-on-cd --shell bash)"
Enter fullscreen mode Exit fullscreen mode
  • Bash: Add to the .bashrc file:
winget install Schniz.fnm
Enter fullscreen mode Exit fullscreen mode
  • Zsh: Add to the.zshrc file:
winget install Schniz.fnm
Enter fullscreen mode Exit fullscreen mode
  • Fish shell: Create ~/.config/fish/conf.d/fnm.fish and add:
fnm env --use-on-cd --shell fish | source
Enter fullscreen mode Exit fullscreen mode
  • PowerShell: To edit the profile in PowerShell, run::
notepad $profile
Enter fullscreen mode Exit fullscreen mode

Add the following line at the bottom of the profile file:

fnm env --use-on-cd --shell power-shell | Out-String | Invoke-Expression
Enter fullscreen mode Exit fullscreen mode

Using NVS:

  • Install the latest Node.js version: fnm install latest
  • Show the current active version: fnm current
  • Install a specific version: fnm install 14.17.0 or fnm install 18
  • Remove versions: fnm uninstall 14.17.0 or fnm uninstall 18
  • View installed versions: fnm ls
  • View available versions for installation: fnm ls-remote
  • Switch versions: fnm use 16.13.0 or fnm use 20
  • Set the default version: fnm default 20
  • Automatic version switching based on specifications in .nvmrc or .node-version files: fnm use

Advantages of fnm:

  • High speed: Fast version switching due to Rust implementation.
  • Cross-platform: Supports most operating systems.
  • Minimal dependencies: fnm does not require many dependencies and works quickly even on old or low-powered machines.

Disadvantages of fnm:

  • Limited documentation: As a new tool, fnm has less documentation and resources for new users, which can make it harder to learn.
  • Less community support: fnm has fewer users, which can make it harder to find solutions to problems.

Volta

Volta is a brand new version manager for Node.js, based on Rust. It makes installing and managing Node.js-easier among other tools. It was created by Kevin Sawicki in 2019 and is still actively maintained. Volta works a little bit different from NVM; instead of keeping track of multiple Node.js versions, it maintains projects and their dependencies but supports other tools like npm and Yarn.

Image description

How to Install and Use

Installation on macOS and Linux:

curl https://get.volta.sh | bash
Enter fullscreen mode Exit fullscreen mode

By default, the script will run and it will automatically update your shell's configuration file. If you don't want that, you can configure the shell yourself:

  • Set the VOLTA_HOME variable to $HOME/.volta.
  • Add $VOLTA_HOME/bin to the beginning of the PATH variable.

Installation for Windows։

Install Volta using Winget:

winget install Volta.Volta
Enter fullscreen mode Exit fullscreen mode

Alternatively, you may download an installer and perform a manual installation from GitHub.

Using Volta:

  • Install a specific Node.js version: volta install node@16.13.0 or volta install node@22
  • Install the latest available or LTS version of Node.js: volta install node@latest or volta install node
  • Set the default version: volta install node@16
  • Show the current active Node.js version: volta which node
  • View installed tool versions: volta list all or volta list node for Node.js, volta list yarn for Yarn
  • Remove a Node.js version: volta uninstall node@16.13.0 or volta uninstall node@22
  • Update a tool to the latest version: volta install <tool>@latest
  • Pin a version for the project: volta pin node@20.16 or volta pin yarn@1.19

Example pinning in package.json**:

"volta": {
  "node": "20.16.0",
  "yarn": "1.19.2"
}
Enter fullscreen mode Exit fullscreen mode

Advantages of Volta:

  • Automatic version management: Selects the required tool versions for each project.
  • High speed: Quickly installs and switches versions due to local caching.
  • Unified environment: All project participants use the same tool versions.
  • Avoids conflicts: Global packages are isolated, preventing dependency issues.
  • Convenience: Automatically locks tool versions for each project, simplifying dependency management and teamwork in CI/CD.
  • Security: Ensures that changes in one project do not affect others.
  • Versatility: Supports installing and managing not only Node.js but also tools like npm, Yarn, and even TypeScript, making it a versatile solution for JavaScript developers.
  • Cross-platform: Supports Windows, macOS, and Linux.

Disadvantages of Volta:

  • Only supports the Node.js ecosystem: Works only with Node.js, npm, Yarn, and JavaScript tools. This limits its use for developers working with other programming languages.
  • Smaller community and support: Less documentation and support compared to NVM or fnm.
  • Limited configuration flexibility: Fewer options for detailed environment configuration.
  • Not all features work the same across platforms: Some features may have limitations or work differently on Windows compared to Unix platforms, causing unpredictable behavior.
  • Dependency on package.json configuration: For Volta to work correctly, it requires precise settings in package.json, adding a dependency on the proper filling of this file.

Prev to Part 1

Next to Part 3

Top comments (0)