updated: 21st of November 2020
published: 22nd of July 2020
Node version manager (NVM) allows you to run different version of Node on your system which is very helpful for testing and ensuring that the Node version you test on is the same as the Node version you run in production.
This is just a quick post on how to install and use (NVM) on Ubuntu 2004.
The following software versions are used in this post
Install NVM
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.0/install.sh | bash
Update ~/.zshrc
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
Verify installation.
nvm --version
# output
0.35.3
Install the latest release of Node.
nvm install node
# Output
Downloading and installing node v14.6.0...
Downloading https://nodejs.org/dist/v14.6.0/node-v14.6.0-linux-x64.tar.xz...
################################################################################################################# 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v14.6.0 (npm v6.14.6)
Creating default alias: default -> node (-> v14.6.0)
Set latest release of Node as the Node version to use.
nvm use node
# output
Now using node v14.6.0 (npm v6.14.6)
Verify Node version in use.
node --version
# output
v14.6.0
which node
# output
/home/bradmin/.nvm/versions/node/v14.6.0/bin/node
Verify NPM version in use.
which npm
# output
/home/bradmin/.nvm/versions/node/v14.6.0/bin/npm
In this post we installed NVM and used it to install and use the latest version of NodeJS.