Easy way to install nvm on Ubuntu

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

# see built-in help page for more usage examples
nvm --help            

Step 1: Download and install the nvm 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

Step 2: Configuration

# Create an environment variable poinitng to nvm home directory
export NVM_DIR="$HOME/.nvm"    


# Run nvm.sh script from the nvm home dir (IF IT EXISTS!)
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"


[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"

Step 3: Verify your installation

nvm --version
# If everything worked you should get a version number printed on the console


References


Written by@NdamuleloNemakh
Welcome to my coding diary, I hope you find it useful!

GitHubTwitter