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:
- Setting the installation path: ```bash
export NVS_HOME="$HOME/.nvs"
2. Clone the repository and install:
```bash
git clone https://github.com/jasongin/nvs "$NVS_HOME"
. "$NVS_HOME/nvs.sh" install
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
- Or with Chocolatey:
choco install nvs
Using NVS:
- Install the latest or LTS version of Node.js:**
nvs add latest
ornvs add lts
- Install a specific version:
nvs add 14.17.0
ornvs add 14
- Remove versions:
nvs rm 14.17.0
ornvs 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.
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: ```bash
curl -fsSL https://fnm.vercel.app/install | bash
- **Homebrew:**
```bash
brew install fnm
Installation for Windows:
- Winget: ```bash
winget install Schniz.fnm
- **Scoop:**
```bash
scoop install fnm
- Chocolatey: ```bash
choco install fnm
**Shell Configuration:**
- **Bash:** Add to the `.bashrc` file:
```bash
eval "$(fnm env --use-on-cd --shell bash)"
-
Bash: Add to the
.bashrc
file: ```bash
winget install Schniz.fnm
- **Zsh:** Add to the`.zshrc` file:
```bash
winget install Schniz.fnm
-
Fish shell: Create
~/.config/fish/conf.d/fnm.fish
and add: ```bash
fnm env --use-on-cd --shell fish | source
- **PowerShell:** To edit the profile in PowerShell, run::
```bash
notepad $profile
Add the following line at the bottom of the profile file:
fnm env --use-on-cd --shell power-shell | Out-String | Invoke-Expression
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
orfnm install 18
- Remove versions:
fnm uninstall 14.17.0
orfnm uninstall 18
- View installed versions:
fnm ls
- View available versions for installation:
fnm ls-remote
- Switch versions:
fnm use 16.13.0
orfnm 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.
How to Install and Use
Installation on macOS and Linux:
curl https://get.volta.sh | bash
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
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
orvolta install node@22
- Install the latest available or LTS version of Node.js:
volta install node@latest
orvolta 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
orvolta list node
for Node.js,volta list yarn
for Yarn - Remove a Node.js version:
volta uninstall node@16.13.0
orvolta 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
orvolta pin yarn@1.19
Example pinning in package.json**
:
"volta": {
"node": "20.16.0",
"yarn": "1.19.2"
}
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 inpackage.json
, adding a dependency on the proper filling of this file.
Top comments (0)