Skip to content

Instantly share code, notes, and snippets.

@skwid138
Last active November 3, 2020 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skwid138/1dca0ff1c4b65fa79d4a21c32cd95838 to your computer and use it in GitHub Desktop.
Save skwid138/1dca0ff1c4b65fa79d4a21c32cd95838 to your computer and use it in GitHub Desktop.
# NVM cheat sheet of use useful commands [Forked From Here](https://gist.github.com/chranderson/b0a02781c232f170db634b40c97ff455)
# ZSH may require the versions to be in quotes (see comments below)
# Check version
node -v || node --version
# List installed versions of node (via nvm)
nvm ls
# Install specific version of node
nvm install 6.9.2
# Set default version of node
# ZSH may require quotes nvm alias default "6.9.2"
nvm alias default 6.9.2
# Set default version of node to the LTS
# ZSH may require quotes ie. nvm alias default "lts/*"
nvm alias default lts/*
# Switch version of node for current terminal
nvm use 6.9.1
# Update the NPM version to the latest release (I believe this is only for the current version of node, meaning if updating both node and npm update node first)
nvm install-latest-npm
# Install the node aliased version
# Reinstall all packages from the currently used node alias version
# Saves you from manually handling the specific versions
# ZSH may require quotes ie. nvm install "node" --reinstall-packages-from=node
nvm install "node" --reinstall-packages-from=node
# Install the LTS versoin
# Reinstall all packages from the LTS version
# ZSH may require quotes ie. nvm install "lts/*" --reinstall-packages-from=node
nvm install "lts/*" --reinstall-packages-from=lts
# Install specific version
# Reinstall packages for specific version
nvm install v5.0.0 --reinstall-packages-from=4.2
# List available remote versions of node (via nvm)
nvm ls-remote
# Remove an alias
nvm unalias "[alias]"
# Update NVM itself -- Check https://github.com/nvm-sh/nvm for the latest version (at the time of this writting it's 0.36.0)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.36.0/install.sh | bash
## UNTESTED ##
# Alias for updating current active version
# The part sed -rn "s/v([[:digit:]]+).*/\1/p" transforms output from nvm current so that only a major version of node is returned, i.e.: v13.5.0 -> 13.
alias nodeupdate='nvm install $(nvm current | sed -rn "s/v([[:digit:]]+).*/\1/p") --reinstall-packages-from=$(nvm current)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment