Skip to content

nvm - program cheatsheet

nvm allows you to quickly install and use different versions of node via the command line.



$ nvm use 16
Now using node v16.9.1 (npm v7.21.1)
$ node -v
$ nvm use 14
Now using node v14.18.0 (npm v6.14.15)
$ node -v
$ nvm install 12
Now using node v12.22.6 (npm v6.14.5)
$ node -v

install nvm

using curl

curl -o- | bash
using wget
wget -qO- | bash
Running either of the above commands downloads a script and runs it. The script clones the nvm repository to ~/.nvm, and attempts to add the source lines from the snippet below to the correct profile file (~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc).

export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/" ] && \. "$NVM_DIR/" # This loads nvm
* paste this into your current bash session or restart your session for the program to become available.

Back to top