Here’s How To Update Node Js To The Latest Version

As a runtime environment, node.js helps create fast and extensible applications. And not only the applications are fast - so are the updates. They come on once every few weeks and enhance security, stability, as well as add some new features.

And if you wish to get an update, there's actually a very simple way to do so. Here are the ways how to update Node on various operating systems

1. Update Node using Package Manager
2. Update Node using Version Manager
3. Update Node using Binary Packages
4. Update Node using an installation wizard (MacOS, Windows, Linux)

1. How to upgrade node using pre-installed Node Package Manager (npm)

You can also use Node Package Manager (npm) to update your node.js. Node comes with the package manager already preinstalled - but before you update Node.js, you need to make sure you npm is at the latest version as well.

  • First, you may want to find out the Node Package Manager version you have, by running an npm -v command.
  • Once done, use npm install [email protected] -g command to install the latest Node Package Manager version available.
  • Finally, use npm -v command to confirm whether your new Node Package Manager was successfully installed.

To update node.js using Node Package Manager, use Node Package Manager’s n module. The following code will help you clear cache from your Node Package Manager and install the latest node.js version

sudo npm cache clean -f

sudo npm install -g n

sudo n stable

Use this command n latest to make sure you install the newest version. You may also want to use n #.#.# command if you’re looking for a specific version of node.js.

2. How to update node js with Node Version Manager (nvm):

Node Version Manager presents a perfect way to update your node.js. Run a C++ compiler and the build-essential and libssl-dev packages, like this:

sudo apt-get update

sudo apt-get install build-essential checkinstall libssl-dev

Now, you can update Node using cURL. Here's the install script you should be using:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash

You can use Wget as well. Here's the script:

wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash

Afterward, use the command command -v nvm  to find out whether the installation process of your new and up-to-date Node Version Manager was a success or not.

If the installation was successful, command -v nvm will output Node Version Manager. If not, and you're getting nvm: command not found, simply close and reopen the terminal, and try the command -v nvm again. This should do the trick.

After you’re done installing your new nvm, installing new node.js versions should be easy. Use this command nvm ls to find out previously installed node.js versions. Also, use ls-remote to discover node.js versions available for installation

Use nvm install #.#.# command to download and install a new version of node.js.

3. How to upgrade node using Binary Packages:

Well, to update node Linux visit nodejs.org and click on the download link to get 64-bit (×86) or 32-bit binary file. Use the console to download the file and make sure that it is the latest version to upgrade node perfectly.

Very important: first unpack the file using xz-utils, and install it using sudo apt-get install xz-utils. Next, complete the installation of the binary code using this code: tar -C /usr/local -strip-comp.

4. How to Upgrade Node on Windows and MacOS

Leave it to Linux users to do things the hard way. You can still do this the hard way, through the terminal (but why would you?). If you're using either Windows or Mac, everything is as simple as running an installation wizard.

To upgrade Node on Windows and Mac, simply visit the Node.js homepage and choose your operating system. From there, a wizard will magically update your Node, and replace the older version with the new one.

how to update node windows mac

Are you a Linux user, and are looking for a similar experience? Well, there might still be a way out for you.

On desktop environments such as Gnome or Unity, you can install and update Node using the graphically interfaced package manager.

One of such examples is Snap Store (on Gnome).

You have finished updating Node js! What now?

The truth is simple - the Node.js modules become outdated all the time and should be updated frequently. The obsolete versions of node.js seriously limit you. Older versions will become incompatible with tools like SQL, and cause the application performance to go down. And yet still, many developers start doing updates only when the things they have stopped working.

That's not good enough. As the legendary software engineer Robert C. Martin once said: "It is not just enough for the code to work”.

You have to make things perfect - and keeping constant Node.js updates is a great step towards that.

Paul joined the Hosting.Review team right from the start as a content writer and marketer. He was the person responsible for establishing a trademark for in-depth web hosting evaluation and superb review articles. Before joining Hosting.Review, Paul was working on various projects as a freelancer. Paul spends his free time reading fantasy books and graphic novels.
Leave a Comment

  1. MaxAxeHax picture MaxAxeHax
    2019 July 24th
    Reply

    Pretty good and clear descriptions. However, as a poor soul who is chained to Windows, I wasted quite some time trying the first couple of methods before realizing the only one applicable is the last one (number 4). Perhaps you could clarify this a bit in the titles of the sections themselves to spare future readers the confusion.

    1. Zangatang picture Zangatang
      2019 July 26th
      Reply

      Wow what a coincidence, I’m was about to continue down that path myself after trying the first method. Thanks for saving me!

    2. Paul Mahony picture Paul Mahony
      2019 July 25th
      Reply

      Hmmmmmm, good point actually. Thank you for your comment!

Get new blog posts by email: