Installing nvm, nodejs and npm on Ubuntu

Those who familiar with Ruby must know how useful was your rbenv and rvm. When it comes to nodejs you have nvm —( node version manager) for the same job. Installing nvm, nodejs and npm on a ubuntu box is just few commands. Let’s get started.

Install nvm — Let’s clone the nvm repository

$ git clone https://github.com/creationix/nvm.git ~/.nvm

Update your profile config file — Depends on what you use .bashrc , .zshrc or .profile you need to add this line. Mine is a .zshrc

$ echo "source ~/.nvm/nvm.sh" >> .zshrc

Find the list of nodejs versions out there

$ nvm ls-remote

Your output would looks like

v0.1.14
v0.1.15
v0.1.16
v0.1.17
…..
v4.1.1
v4.1.2
v4.2.0
v4.2.1
v5.0.0

Install the required version of your choice — I’m going to go for the latest stable version here

$ nvm install v5.0.0

This will install both nodejs v5.0.0 and npm. Let’s verify

➜ ~ node -v && npm -v 
v5.0.0
3.3.6

Additionally you can set the default nodejs version using

nvm alias default 5.0.0

And we’re ready — Happy coding :)

--

--

Solution Architect | Microservice, Serverless Enthusiasts — Connect at https://www.linkedin.com/in/randika/

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