Similar to nvm-sh but meant to be faster (on startup at least).
- Install nodejs versions
- Use nodejs version defined in
.nvmrc,.znvmrcorDockerfile- To automatically use the version add
znvm hookwdchangeto your.zshrc
- To automatically use the version add
- Aliases for nodejs versions: for example
defaultcan be an alias forv12 - Support of closest version:
- if a certain version is not installed, it will try to find the closest version and will choose the newest one
for example if you try to use
v10.0.0but you don't have it installed, it will usev10.24.0if you have it installed
- if a certain version is not installed, it will try to find the closest version and will choose the newest one
for example if you try to use
- Autocompletion for znvm commands
- Load default nodejs version on shell startup
You shell must be zsh
The following commands also needed for operation:
curlawktailheadcutsortuniq
git clone https://github.com/Ajnasz/znvm $HOME/src/znvm
Edit you .zshrc and the following line to enable the plugin:
# enable znvm plugin
. $HOME/src/znvm/znvm.plugin.zsh
# enable autocompletion for znvm
fpath+=$HOME/src/znvm
# load default nodejs version
# but only if it's not set (for example it will be set if you use tmux)
# remove the if statement if you want to make sure the default version used in a new shell
if ! znvm current > /dev/null
then
znvm use default
fi
# load version defined in .nvmrc
znvm hookwdchangecd $ZSH
git submodule add https://github.com/Ajnasz/znvm custom/plugins/znvmInstall in zgenom
Add zgenom load Ajnasz/znvm in your .zshrc with your other zgenom load commands.
How to enable plugins in oh-my-zsh
# load default nodejs version
znvm use default
# load version defined in .nvmrc
znvm hookwdchangeThe ZNVM_DIR environment variable, default value is $HOME/.znvm
ZNVM_DIR="$HOME/.znvm"
The ZNVM_SEARCH_FILENAMES environment variable is a list of filenames (separated by space) znvm will look for whenever it executes the chpwd hook listener. Default value is .znvmrc .nvmrc Dockerfile
To disable Dockerfile read remove it from the list:
ZNVM_SEARCH_FILENAMES=".znvmrc .nvmrc"
To install the latest nodejs v12:
znvm install v12To install nodejs v8.1.1
znvm install v8.1.1znvm alias default v12znvm use v12Use a default version
znvm use defaultAdd the following line to the .zshrc
znvm hookwdchangeThe hook will traverse directory structure upwards from the current directory looking for the files defined in $ZNVM_SEARCH_FILENAMES every time you change directory.
That will add a hook, which executes every time you change directory. The hook listener will search .znvmrc, .nvmrc and Dockerfile in the directory you entered to. If no file found, it will try to find it in the parent directory until it reaches the root directory.
When it searches in a Dockerfile, it will try to extract the version number from FROM node: line.