Skip to content

Instantly share code, notes, and snippets.

@puncoz
Created March 7, 2020 11:47
Show Gist options
  • Save puncoz/c91c5dcbdddbbc6c0f8b094b1fbcc52a to your computer and use it in GitHub Desktop.
Save puncoz/c91c5dcbdddbbc6c0f8b094b1fbcc52a to your computer and use it in GitHub Desktop.

Basic NVM Commands

Repo:

https://github.com/nvm-sh/nvm

To download, compile, and install the latest release of node, do this:

nvm install node # "node" is an alias for the latest version

To install a specific version of node:

nvm install 12.16.1 # or 10.10.0, 8.9.1, etc

or,
nvm install --lts / nvm install --lts=argon / nvm install 'lts/*' / nvm install lts/argon

list available versions

nvm ls-remote

list installed versions

nvm ls

use the installed version

nvm use node

or,
nvm use v12.16.1

upgrade node using nvm

nvm install NEW_VERSION --reinstall-packages-from=OLD_VERSION

eg:

nvm install v12.16.1 --reinstall-packages-from=v12.8.1

then, if you want, you can delete your previous version with:

nvm uninstall OLD_VERSION

Alternatively,

nvm install node --reinstall-packages-from=$(nvm current)

Bash alias

alias nodeupdate='nvm install $(nvm current | sed -rn "s/v([[:digit:]]+).*/\1/p") --reinstall-packages-from=$(nvm current)'

To set a default Node version

nvm alias default node

or,
nvm alias default v12.16.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment