nvm.fish
Manage Node.js versions
TLDR
Install a specific version of Node.js
Use a specific version of Node.js in the current shell
Set the default Node.js version
List all available Node.js versions and highlight the default one
Uninstall a given Node.js version
SYNOPSIS
nvm.fish itself is typically sourced or loaded via a Fish plugin manager (e.g., Fisher, Oh My Fish).
Once loaded, nvm commands become available:
nvm [
Examples:
nvm install node
nvm use 16
nvm ls
PARAMETERS
install
Installs a specific Node.js version or the latest stable version.
use
Switches the active Node.js version for the current shell session.
ls
Lists all installed Node.js versions and indicates the current one.
alias
Creates or updates an alias for a specific Node.js version.
uninstall
Uninstalls a specific Node.js version.
current
Displays the currently active Node.js version.
exec
Executes a command with a specific Node.js version without changing the current shell's version.
deactivate
Deactivates nvm, reverting to the system's default Node.js (if any).
DESCRIPTION
nvm.fish is a community-contributed Fish shell plugin that provides seamless integration for Node Version Manager (nvm) functionality within the friendly interactive shell. Unlike nvm which is primarily designed for Bash and Zsh, nvm.fish handles the intricacies of Fish's path and function management, allowing users to install, switch, and manage multiple Node.js versions without leaving their Fish environment. It smartly loads nvm on demand to improve shell startup performance, ensuring that common nvm commands like nvm install, nvm use, nvm ls, and nvm alias work as expected. This makes Node.js development in Fish a much smoother and more efficient experience, bridging the gap between a popular version manager and a modern shell.
CAVEATS
Requires the core nvm (Node Version Manager) to be installed and accessible, as nvm.fish acts as a wrapper, not a standalone replacement. Due to Fish shell's distinct function and path handling, its behavior can sometimes differ from nvm's native operation in Bash/Zsh. While designed for lazy loading, frequent Node.js version switches can still incur some performance overhead. Its functionality is intrinsically linked to and dependent on the underlying nvm Bash/Zsh scripts.
INSTALLATION
nvm.fish is most commonly installed using a Fish plugin manager like Fisher. For example, to install with Fisher:
fisher install jorgebucaran/nvm.fish
Alternatively, it can be manually sourced in your ~/.config/fish/config.fish file.
LAZY LOADING
A key design principle of nvm.fish is 'lazy loading'. It avoids loading the full nvm script into memory during shell startup. Instead, nvm is sourced only when an actual nvm command is invoked for the first time, ensuring fast shell initialization times.
HISTORY
nvm.fish emerged from the community's need to leverage the popular nvm tool within the Fish shell, which has different scripting paradigms compared to Bash or Zsh. Early solutions often involved manual hacks or incomplete functions. This project streamlined the process, providing a robust and well-maintained bridge. Its development focuses on ensuring ongoing compatibility with nvm's evolving feature set and adapting to Fish shell's unique environment management system, making nvm a first-class citizen in Fish.


