Crates.io | snm |
lib.rs | snm |
version | 0.8.0 |
source | src |
created_at | 2021-01-02 15:43:00.88204 |
updated_at | 2021-09-13 06:33:02.780532 |
description | Smol and simple node version manager |
homepage | https://github.com/numToStr/snm/ |
repository | https://github.com/numToStr/snm/ |
max_upload_size | |
id | 330623 |
size | 159,539 |
🤏 Smol Node Manager
Terminal: kitty | Prompt: starship
.nvmrc
, .node-version
and package.json
cargo
(Linux/macOS/Windows)cargo install snm
yay
or pamac
(Arch Linux)Why snm is available for Arch? Because I love Arch Linux
# Using `yay`
yay -S snm
# Using `pamac`
pamac build snm
Check out the Release page for prebuild binaries for snm
, available for different operating systems.
curl -fsSL https://git.io/JLFnA | bash
Available Params
--install-dir
: Set a custom directory for binary installation. Defaults to $HOME/.snm
--skip-shell
: Skip appending shell specific loader to the $SHELL
config file.NOTE:
snm
uses symlinks underneath to manage aliases. So, If you are using Windows make sure you have enabled Developer Mode or your user has permission to create symlinks. You can read more here
Add the following line to your ~/.bashrc
eval "$(snm env bash)"
Add the following line to your ~/.zshrc
eval "$(snm env zsh)"
Add the following line to your ~/.config/fish/config.fish
snm env fish | source
Add the following line to your ~\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
snm env pwsh | Out-String | Invoke-Expression
You can find more about the powershell profile here
Options | Env Variable | Description |
---|---|---|
--snm-dir |
SNM_DIR |
Directory where the all files and aliases are saved |
--node-dist-mirror |
SNM_NODE_DIST_MIRROR |
Nodejs download mirror |
Example:
snm [--snm-dir="~/.something/else"] [--node-dist-mirror="https://myrelease.com"]
Flags | Description |
---|---|
--no-use |
Only download the release |
--version |
Prints the version |
--help |
Prints the help doc |
snm install <version|alias>
: Install Nodejs with the provided version or lts codename# Following command will downloads and installs the most recent 14.x.x release
snm install 14
# Following command will download the most recent lts/fermium release
snm install lts/fermium
# or snm install lts-fermium
# or snm i lts-fermium
snm uninstall [version|alias]
: Removes the installed NodejsIf given an alias like
ten
orlts-fermium
then it will remove the version which the alias is pointing at and all the aliases which are pointing to the same version. Also, uninstalling a version will throw an error, if multiple installation is found in the same semver range or if the provided version/alias is active, add--force
flag to override this behavior.
# Following command will remove 14.x.x installation
snm uninstall 14
# Following command will remove the lts/fermium release
snm uninstall lts/fermium
# or snm uninstall lts-fermium
# or snm rm lts-fermium
# Add --force flag to forcefully remove the active version
snm uninstall --force 16
snm use [version]
: Change Nodejs version, Supports .nvmrc
and .node-version
# Following command will use a downloaded version matching 10.x.x
snm use 10
# Searches for `.nvmrc` or `.node-version`, if <version> is not provided
snm use
snm lts
: Installs the recent lts release
snm latest
: Installs the recent current release
snm ls
: List all the local downloaded versions with their aliases
snm ls-remote [version]
: List remote Node.js versions
# Following command list 20 results with version matching 14.x.x
snm ls-remote 14
# This will show all the results
snm ls-remote 14 --all
# Following command will show 25 results
snm ls-remote 14 --count 25
snm alias <version> <name>
: Alias a version to a common name# Following command will alias the version 10 to ten
# 10 can refer to any semver release ie 10.15.0
snm alias 10 ten
snm unalias [name]
: Removes aliases# Following command will removes alias `ten`
snm unalias ten
# Removes all the aliases
snm unalias --all
snm exec <version>
: Executes a command within snm context with the modified PATH# Following command will output the Nodejs version
snm exec 10 -- node -v
# Following command will run yarn with Nodejs v10.x.x
snm exec 10 -- yarn start
snm purge
: Remove all the installed versions and aliases. Except the active version.# Doesn't remove the active version
snm purge
# Will remove everything including the active version
snm purge --all
snm which <version>
: Prints path for the downloaded Nodejs version
snm help <subcommand>
or snm <subcommand> --help
: Help doc for the subcommand
NOTE: This is a small part of help doc. Please make sure to read the inbuilt help
snm
binary has inbuilt completions supports. Please follow the instruction to generate completions according to your shell.
snm completions zsh
snm completions bash
snm completions fish
snm completions pwsh
After generating the completions, please follow your shell instructions on how to load and use them.
PRs are always welcome. You can help me by adding more tests :).
First, You need to install rust toolchain via rustup.
Minimum Supported Rust Version (MSRV): 1.54.0
git clone https://github.com/numtostr/snm
cd ./snm
# For debug build
cargo build
# For release build
cargo build --release
# Same as running `snm --help`
cargo run -- --help
# Same as running `snm lsr 14`
cargo run -- lsr 14
This project would not be possible without these awesome projects.