Automatic Node Version Switcher is written in Rust, with a loving tip-of-the-hat to avn
ANVS is a Rust-based tool that automatically switches your Node.js version when you cd into a directory with a .nvmrc, .node-version, or package.json file. It automatically returns to your default version when you leave.
- π Fast: <100ms activation time (2-3x faster than avn)
- π Compatible: Works with nvm, fnm, and n
- π Smart: Automatically returns to default version when leaving projects
- π€ Auto-install: Prompts to install missing versions
- βοΈ Configurable: Customize behavior via
~/.anvsrc - π Safe: Written in Rust with checksum verification
- π¦ Easy: Install via npm, no manual binary downloads
Initialize anvs with auto-detection (recommended):
# Install
npm install -g anvs
# Quick setup with auto-detection (default, < 30 seconds)
anvs initOr use advanced mode for full customization:
anvs init --advancedThe wizard detects your shell and Node.js version manager, then guides you through setup.
Quick Mode (default):
- Auto-detects shell and version managers
- Shows summary and asks for confirmation
- Completes in < 30 seconds
- Recommended for most users
Advanced Mode (--advanced):
- Step-by-step customization
- Full control over all settings
- Takes 1-2 minutes
- For users with specific requirements
anvs is installed to a central directory (~/.anvs) to ensure it's always available, regardless of the active Node.js version.
# Step 1: Install the package
npm install -g anvs
# Step 2: Set up your shell
anvs init# Step 1: Tap the repository
brew tap olvrcc/anvs
# Step 2: Install anvs
brew install anvs
# Step 3: Set up your shell
anvs init# Install from source
cargo install --git https://github.com/olvrcc/anvs
# Set up your shell
anvs initAfter installation via any method, restart your shell or run:
source ~/.bashrc # or ~/.zshrcnpm:
npm update -g anvsNote for nvm users: Global packages are Node version-specific in nvm. If you installed anvs while on Node v20 but later switched to Node v22, the global package only exists in v20. To uninstall completely, switch back to the Node version where anvs was installed before running npm uninstall -g anvs.
Homebrew:
brew upgrade anvsCargo:
cargo install --git https://github.com/olvrcc/anvs --forceIf you're upgrading from xvn to anvs, see the Migration Guide.
Quick migration:
xvn uninstall
npm install -g anvs
anvs initFor detailed instructions, troubleshooting, and configuration migration, see docs/XVN_TO_ANVS_MIGRATION.md.
Just cd into a directory with a version file:
cd ~/my-project # anvs automatically switches Node.js version
cd .. # anvs switches back to your default Node.js versionWhen you leave a project directory (one with a .nvmrc or other version file), anvs automatically switches back to your default Node.js version. This ensures you're always on your preferred version when not in a project.
For nvm users:
- anvs uses your
defaultalias:nvm alias default 20.11.0 - Check your default:
nvm version default
For fnm users:
- anvs uses fnm's default version
- Check your default:
fnm default
Configuration:
# In ~/.anvsrc
use_default: true # (default: true)Disable this behavior if you prefer manual version switching:
anvs set use-default # Interactive toggleanvs supports multiple version file formats:
-
.nvmrc- Standard nvm format with exact version or alias18.20.0 -
.node-version- Alternative format, same as .nvmrc20.11.0 -
package.json- npm standard with semver ranges{ "engines": { "node": ">=18.0.0" } }Supports semver ranges:
^20.0.0,~18.20.0,>=18 <21,18.x
anvs activate # Activate version for current directoryanvs status # Show current configuration and activation timingCreate ~/.anvsrc:
# Version managers (in priority order)
plugins:
- nvm
- fnm
# Auto-install missing versions
auto_install: prompt # or 'always' or 'never'
# Automatically switch to default version when leaving projects
use_default: true # or 'false' to disable
# Silent mode (no output)
silent: false
# Version file priority (first match wins)
version_files:
- .nvmrc
- .node-version
- package.json # optional, supports semver rangesProject-level configuration (.anvs.yaml in project root):
# Override global settings for this project
auto_install: always
silent: true- β nvm (Node Version Manager)
- β fnm (Fast Node Manager)
- β³ n (planned for future release)
- β³ asdf (planned for future release)
- Node.js 14+
- nvm or fnm installed
- bash or zsh shell
- Linux or macOS (x64 or arm64)
- Windows support planned for future release
To completely remove anvs and clean up all configuration:
anvs uninstallThis command will:
- Detect all anvs installations (npm, Homebrew, Cargo)
- Remove
~/.anvsdirectory - Remove
~/.anvsrcconfiguration - Remove shell integration from
.bashrc/.zshrc - Provide instructions for uninstalling external packages
Use --force to skip the confirmation prompt:
anvs uninstall --forceThis can happen after installation if your shell hasn't been restarted. Make sure you have run anvs init and restarted your shell.
Verify that ~/.anvs/bin is in your PATH:
echo $PATHVerify the anvs binary is in the right place:
which anvs
# Should output: /Users/your-name/.anvs/bin/anvsMake sure you ran anvs init and restarted your shell.
Verify the hook was added to your profile:
grep anvs ~/.bashrc # or ~/.zshrcCheck that your version manager is installed:
nvm --version # or fnm --versionCheck that anvs detects your version file:
anvs statusShell not detected:
anvs init --shell zsh # or bashVersion manager not detected:
- Ensure nvm or fnm is installed and in PATH
- Use advanced mode to specify manually
Permission denied:
- Check write permissions for ~/.anvsrc and shell config files
- Run with sudo if necessary (not recommended)
Enable debug output to see what anvs is doing:
ANVS_DEBUG=1 cd my-projectanvs is installed to ~/.anvs/bin and this directory is added to your shell's PATH. It integrates with your shell using the chpwd hook (bash/zsh) and communicates with the parent shell via file descriptor 3 (FD:3).
When you cd into a directory:
- Shell hook triggers on directory change.
- anvs searches for version files (
.nvmrc, etc.). - anvs queries configured version managers (nvm, fnm) for the version.
- If the version is missing, anvs prompts to install it.
- An activation command is generated and written to FD:3.
- The parent shell executes the command, changing the Node.js version.
This approach ensures anvs can modify the parent shell environment safely.
# Clone the repository
git clone https://github.com/olvrcc/anvs.git
cd anvs
# Build
cargo build
# Run tests
cargo test
# Install locally for development
cargo install --path .
anvs initContributions are welcome! Please see CONTRIBUTING.md for guidelines.
For detailed architecture documentation, see docs/ARCHITECTURE.md.
MIT - see LICENSE for details.
Inspired by avn by Whitney Young. anvs reimagines the concept in Rust for improved performance and reliability.