Easy way to install nvm on Ubuntu 18.04

Nvm — Node version manager

As the name suggests, nvm allows you to run multiple versions of nodejs on your PC.

  • Example usage:
$ nvm install 10.0.0    # Install node version 10.0.0$ nvm use 10.0.0        # Use node version 10 (if it is installed)
$ nvm run 10.0 app.js # Run app.js using node version 10.0.x
$ nvm --help # read full nvm manual

Step 1: Download and install package

$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash# Alternatively 
$ wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
Image for post
Sample output after downloading and running the install script

Step 2: Configuration

$ export NVM_DIR="$HOME/.nvm"    $ [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"$ [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
  • Line 1: Add $NVM_DIR environment variable on your current shell session
  • Line 2: Run nvm.sh script if it exists, i.e. [ -s “$NVM_DIR/nvm.sh” ]
  • Line 3: Run bash_completion script if it exists

Step 3: Verify your installation

  • Check the installed version, by running:
$ nvm --version# Sample output: 0.35.3

Written by

Former Glorified Electrician(aka Electrical Engineer). Now a Software Developer working on complex Enterprise Software. Lets connect on twitter @NdamuleloNemakh

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store