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

Avatar

Fiona O’Connell

10 comments

2020 February 7th

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.


Leave a Comment

* your email will not be displayed

User comments

Mark Hagers picture
Mark Hagers

2020 May 14th

Surprised to find the most convenient way to upgrade node on MacOS isn't mentioned: using homebrew (https://brew.sh/) By first installing homebrew, you can use it install and upggrade node (and... Read more

Surprised to find the most convenient way to upgrade node on MacOS isn't mentioned: using homebrew (https://brew.sh/) By first installing homebrew, you can use it install and upggrade node (and a host of other unix software). Caveat: if you have already installed node you must uninstall before using brew to install it, brew will only update software it installed itself.

    Dominik Urban

    2020 May 27th

    And for Win with: choco install nodejs

    And for Win with: choco install nodejs

Alfredo Rafael Pabon picture
Alfredo Rafael Pabon

2020 April 17th

This is exactly what I needed! Thank you sooooo much for posting, man ^_^

This is exactly what I needed! Thank you sooooo much for posting, man ^_^

Deloris Wallenda picture
Deloris Wallenda

2019 October 25th

Very nice post. I just stumbled upon your blog and wished to say that I have truly loved surfing around your blog posts.

Very nice post. I just stumbled upon your blog and wished to say that I have truly loved surfing around your blog posts.

Stephanie picture
Stephanie

2019 October 20th

In the section "How to upgrade node using pre-installed Node Package Manager (npm)" the command `sudo npm install -g n<` gives an error of `-bash: syntax error near unexpected token... Read more

In the section "How to upgrade node using pre-installed Node Package Manager (npm)" the command `sudo npm install -g n<` gives an error of `-bash: syntax error near unexpected token `newline'`. Should actually be "sudo npm install -g n"

    Earl Whitmore

    2020 February 7th

    Thank you Stephanie, we fixed this little error.

    Thank you Stephanie, we fixed this little error.

    Carlton

    2020 February 6th

    I came to say exactly the same thing.

    I came to say exactly the same thing.

MaxAxeHax picture
MaxAxeHax

2019 July 24th

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... Read more

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.

    Zangatang

    2019 July 26th

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

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

    Paul Mahony

    2019 July 25th

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

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