Best way to update & manage your node.js versions

Tue Feb 21 2017

Paul Shan

Many a times you face issues with the version of your installed node js. Some packages may ask for latest versions to work smoothly and some others may say they can not work properly with the latest versions. So sometimes the versions of node js really become a headache and you face the requirement to upgrade or downgrade them.

What I do not prefer

There are couple of ways to do that and I’ve found one of the most popular ways people described is by using the npm package n.
But I found it not up to the mark due to the following reasons.

  • Lot of people reported about the package not being stable.
  • Unnecessary requirement for sudo.
  • Slower than nvm.
  • The community is with nvm. Right now nvm has 3 times the stars than n in github.

What I do prefer

I think you already guessed what I want to say. Yes, I think nvm is a better and secure way to update, manage or remove your node js versions. I personally am doing upgrade and downgrade all the times now a days because I work both with ember-cli and angular-cli. Ember-cli wants the node to be below v6.9 and angular-cli wants it above 6.9. So you can guess my situation.

Manage Node js with nvm (Mac/Linux)

Step 1

First of all you need to have nvm (node version manager) installed in your computer. You can run the following curl command to install that.

curl -o- | bash

This should be sufficient to install nvm properly without errors. However if you want to check details or other ways about installation, you can check the document in github.

Step 2

Now that your nvm is installed and ready to be used; install the required version of node.js using nvm in your computer. The command below will so it for you.

nvm install 7.0.0

You can install multiple versions of node js too.

Step 3

Now that your desired version of node js is installed; you can switch to that using the command below.

nvm use 7.0.0

The command above will make the current used version of node js in your computer as 7.0.0. To verify it, you can run the version command of node.

node -v

Check the installed versions

If any any point you want to see which versions are installed, you can run the following nvm command to list all of them.

nvm ls

Delete a particular version

Even though multiple installed versions will not bother you; as at a time you will be using only one. But if you feel you have some unnecessary versions you can always remove them using the following command.

nvm uninstall 6.0.0

Update node js to latest version

Many a time you need to install the latest available node.js in your machine. However going to the official node.js website, finding out the latest version and installing and running that using the previously mentioned steps are a little tedious task. That’s why I’ve came up with the following bash function.

update_nodejs () {
    NODE_LATEST=$(nvm_remote_versions | grep '^v' | tail -1)

    echo "Updating node.js from ${NODE_CURRENT} to ${NODE_LATEST}..."

    nvm install ${NODE_LATEST}

    nvm use ${NODE_LATEST}

All you need to do is to open up your .bash_profile and insert this code snippet over there. Restart your terminal & you will be able to use the command update_nodejs, which will update the node.js in your machine to the latest version.

There is a problem with nvm when using global packages. If you install a package globally and then switch the node js version to some other; you wont be able to access the the global package there. To resolve this, check how to forward global packages in nvm.


Today everyone knows the importance of a lightning-fast website and how the speed impacts the conversion rate of a business. Today, everyone wants the site to be a PWA so that the mobile users can have an app-like experience with the website because, for the majority of the merchants, the customers come through mobile devices.
Tue Apr 20 2021
Here we are going to see how you can manage backup and restore of Postgres database with docker.
Thu Sep 03 2020
Image sliders or carousels always have increased the UI attraction of websites and they are pretty useful for reflecting the major roles/products too. In case, I am having a website that sells tee-shirts,
Mon Apr 30 2018

About VoidCanvas

This blog was created out of hobby and talks mostly about technology, web development, JavaScript, NodeJS and related topics. Thank you for reading my blog.

Copyright 2022 -

Popular Articles

Authentication using Google's oAuth api with node.js

Thu Mar 10 2016

OAuth authentications are pretty popular now a days and another thing which is popular is JavaScript. This article shows how to plugin google’s oAuth api for authentication in your own node application.

CSS3 Loader Snippet Collection: (Part 2 - Squares)

Sat Mar 01 2014

This is a continuation of my CSS3 loader snippet collection series. I've provided spinning css3 animation loader in the part 1 of this series and here in part 2, I'm providing various square type loading