NVS (Node Version Switcher) is a cross-platform tool for managing multiple Node.js versions. It allows you to easily install, switch between, and manage different Node.js versions and their associated npm packages.
nvs --version
# Using winget (Windows 11+)
winget install jasongin.nvs
# Or using chocolatey
choco install nvs
# Manual installation
$env:NVS_HOME="$env:LOCALAPPDATA\nvs"
git clone https://github.com/jasongin/nvs "$env:NVS_HOME"
. "$env:NVS_HOME\nvs.ps1" install
export NVS_HOME="$HOME/.nvs"
git clone https://github.com/jasongin/nvs "$NVS_HOME"
. "$NVS_HOME/nvs.sh" install
# Install latest version
nvs add latest
# Install latest LTS version
nvs add lts
# Install specific version
nvs add 18.20.0
# Install with specific architecture
nvs add 18.20.0/x64
# Use a version in current shell session
nvs use 18.20.0
# Use LTS version
nvs use lts
# Set default version (permanent)
nvs link 18.20.0
# Remove default link
nvs unlink 18.20.0
# List locally installed versions
nvs ls
# List available remote versions
nvs ls-remote
# Filter remote versions
nvs ls-remote 18
nvs ls-remote lts
nvs rm 16.20.0
Enable automatic switching based on .node-version or .nvmrc files:
# Enable auto-switching
nvs auto on
# Disable auto-switching
nvs auto off
# Manual trigger for current directory
nvs auto
# Create an alias
nvs alias myproject 18.20.0
# List all aliases
nvs alias
# Remove an alias
nvs alias myproject
# Run a script with specific Node version
nvs run 18.20.0 app.js
# Execute a command with specific version
nvs exec 18.20.0 npm test
# Migrate global npm packages from one version to another
nvs migrate 16.20.0 18.20.0
# List configured remotes
nvs remote
# Add custom remote (e.g., nightly builds)
nvs remote add nightly https://nodejs.org/download/nightly/
# Use custom remote
nvs add nightly/18
.node-version or .nvmrc filenvs lsnvs add latestnvs use latestnvs migrate nvs link latestnvs command not found, ensure NVS is properly installed and shell is restartedNVS_HOME environment variable points to correct directorynvs which to verify version pathsNVS_HOME: Directory where NVS stores Node.js versions (default: ~/.nvs on Mac/Linux, %LOCALAPPDATA%\nvs on Windows)NVS_NODE_HOME: Alternative location for Node.js installationsNVS integrates with Visual Studio Code for debugging with specific Node.js versions. Configure in .vscode/launch.json:
{
"runtimeArgs": ["18.20.0"],
"windows": { "runtimeExecutable": "nvs.cmd" },
"osx": { "runtimeExecutable": "nvs" },
"linux": { "runtimeExecutable": "nvs" }
}
共 1 个版本