Lighter, faster and cross-platform alternative to nvm.
nvs is a simple tool that does only the following things:
- downloads
nodejsbinaries, based on full or partial version numbers - manages downloaded
nodejsversions - activates selected
nodejsversion for current terminal - manages default
nodejsversion, used for new terminal sessions
Supported platforms: Linux, macOS, Windows (with some type of bash installed, like git bash etc.).
-
Clone this repository
git clone https://github.com/pawelt/nvs.git ~/nvs -
Setup
nvsstartup scriptAdd these two lines to your
~/.bashrc:export NVS_DIR=~/nvs [ -s $NVS_DIR/nvs.sh ] && source $NVS_DIR/nvs.shNOTE: If you're using
git bash, you can put the above snippet in:C:\Program Files\Git\etc\profile.d\aliases.sh -
Start new shell, install and activate the latest node
nvs-i && nvs-use && nvs-default-setThat's it! Run
nvs-hfor complete list of commands.NOTE: Withouth an argument,
nvs-iinstalls the latest available version of node. To install other version, for ex.: most recent8.x.xversion, run this instead:nvsi 8 && nvs-use && nvs-default-save
If you want to have nvs available in the standard Windows cmd.exe shell:
-
Create
%USERPROFILE%\cmdrc.cmdfile with the following content:set NVS_DIR=%USERPROFILE%\nvs if exist %NVS_DIR%\nvs.cmd call %NVS_DIR%\nvs.cmd -
Run this command to add it to autorun:
REG add "HKCU\Software\Microsoft\Command Processor" /v "AutoRun" /d "%USERPROFILE%\cmdrc.cmd" /for just use the
nvsrc.cmdfile that comes withnvs:REG add "HKCU\Software\Microsoft\Command Processor" /v "AutoRun" /d "%USERPROFILE%\nvs\nvsrc.cmd" /f
To override default bash.exe location: C:\Program Files\Git\bin\bash.exe
- Create
nvs-bash-exe.txtfile in thenvsfolder - Paste full
bash.exepath there, ex.:D:\Git\bin\bash.exe
To print this help screen run nvs-h.
```
Commands:
nvs print version info and short help
nvs-h print full help screen
nvs-use [v] activate the newest installed version matching the filter
nvs-ls [v] list installed node versions with optional filter
nvs-ls-one [v] same as nvs-ls, but prints only the first version found
nvs-find [v] list available node versions with optional filter
nvs-find-one [v] same as nvs-find, but prints only the first version found
nvs-i [v] installs the newest version matching the filter
nvs-default-get print currently set default version
nvs-default-set save currently active version as default
Filters:
All [v] filters are partial or full versions, ex.: 8 9.1 10.7.0
Empty [v] filter means 'match all versions'
Install and configure the latest version of node:
nvs-i && nvs-use && nvs-default-set
To uninstall a version simply remove its directory from $NVS_DIR/v
```
For all supported platforms nodejs versions are changed by manipulating system PATH environment variable. No magic, no symlinks swapping or files copying.
Because version changing requires simple string replacement and settinv an env variable, the process is very fast, compared to nvm.