How to Update Node.js to Latest Version (Linux, Ubuntu, OSX, Windows)

As with so many open-source technologies, Node.js is a fast-moving project. Minor updates come out every few weeks to boost stability and security among all version branches.

Methods abound for updating Node on any operating system, so we don’t have an excuse to fall behind. We’ve compiled some of the simplest and most effective ways to install the newest version of Node on Linux-based, Windows, and macOS machines. Before we get started, check which version of Node.js currently using by running node-v in a command line terminal.

 

3 Ways to Update Node Versions on Linux-Based Machines

We’re covering all bases with updating Node on Linux-based operating systems, but Option 1 is most recommended method for simplicity and effectiveness. If extenuating circumstances prevent from going the Node Version Manager route, read for instructions on updating Node through package managers or binary packages.

 

1. Update Node Using Node Version Manager

Node Version Manager, or nvm, is the best method to updating Node. We’ll need a C++ compiler, as well as the build-essential and libssl-dev packages. Run an update first, then get the packages:

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

To install or update nvm, you can get the install script by using cURL:

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

Then close and re-open the terminal first, but we can verify a successful installation by using command -vnvm. The command will output nvm if everything worked.

Once we’re set up, installing updated versions of Node is a breeze. we can check what versions are currently installed with nvm, see what is available to install by using nvm ls-remote.

Download, compile, and install newer versions of Node with nvm install#.#.#, obviously substituting the #s for the Node version you want. You can tell nvm which version to use in each new shell with nvm use#.#.# and set a default with alias: nvm alias default node.

 

2. Update Node Using a Package Manager

If nvm isn’t for us, a package manager is next best bet. Node package manager, or npm, helps you discover, share, and use code, along with managing dependencies.

Node comes with npm pre-installed, but the manager is updated more frequently than Node. Run npm -v to see which version we have, then npm install npm@latest-g to install the newest npm update. Run npm -v again if we want to make sure npm updated correctly.

To update Node, we’ll need npm’s handy n module. Run this code to clear npm’s cache, install n, and install the latest stable version of Node:

sudo npm cache clean -f                                                                                                             sudo npm install -g n                                                                                                                   sudo n stable

To install the latest release, use nlatest. Alternatively, run n#.#.# to get a specific Node version.

 

3. Update Node (Ubuntu/Linux/Debian/CentOS) Using Binary Packages

Let’s be honest — we probably don’t want to go this route. If we’re desperate, however, go to the official Node.js downloads page to get the 32-bit or 64-bit Linux binary file. Then download the file from a browser, but we prefer using the console. Keep in mind, the specific Node version might change as updates are released.

wget https://nodejs.org/dist/v6.9.2/node-v6.9.2-linux-x64.tar.xz

To unpack the file, we’ll need xz-utils; to install it, run sudo apt-get install xz-utils. Next, use this code to install the binary package in usr/local:

tar-C/usr/local--strip-components1-xJf node-v6.9.2-linux.x64.tar.xz

Now that we have Node and npm, consider giving Option 2 a try for the next update

 

How to Update Node (Windows/macOS) Using Installers on Nodejs.org

The Node.js downloads page includes binary packages for Windows and macOS — but why make our life more difficult? The pre-made installers — .msi for Windows and .pkg for macOS — make the installation process unbelievably efficient and understandable. Download and run the file, and let the installation wizard take care of the rest. With each downloaded update, the newer versions of Node and npm will replace the older version.

Alternatively, macOS users can use the npm and n instructions above.

Take a quick help, premium support from our Nodejs Experts. Try Auto-Proposal and get instant support for your migration and upgradation.



Was this article helpful?



You are freelancing Ninja?

Try Toogit Instant Connect today, The new virtual assistant for your freelancing world.