Node.js, similarly to a lot of other non-proprietary software, is a project which is moving swiftly. Every few weeks trivial updates would come out to enhance security and stability including all the version branches.
Due to the abundance of procedures to update the Node on each and every operating system, leave you with no excuses to lag behind!
Some of the most efficient and user-friendliest methods are compiled for the installation of the most recent edition of Node on machines dependent on Windows, MacOs & Linux.
However, firstly you should assess which edition of Node.js you are using at the moment, running node –v within a command-line interface.
3 Methods for Updating Node Editions on Machines based on Linux
Attention was given to every aspect with updating Node on operating systems based upon Linux. However, the first option is the most recommendable procedure for both efficiency and simplicity.
When an uncontrollable situation is preventing you to follow the NVM (Node Version Manager) route, you will find instructions further on in this article how to update the Node via binary packages or package managers.
Updating Node Using NVM (Node Version Manager)
Nvm or Node Version Manager poses to be without doubt the best technique to update Node. A c++ compiler and libssi-dev, as well as build-essential packages, are required.
First you have to run an update, before getting the packages.
- sudo apt get-update
- sudo apt get – install build-essential; check-install libssl-dev
To update & install nvm, get the installing script, using cURL
1 curl –o- – https://raw.githubusercontent.com/creationix/nvm/nvm/v0.32.1/install.sh | bash
First, you will need to close & reopen the terminal. However, you will be able to verify whether the installation was successful using the command-v nvm. If everything is working, nvm will be put out by the command.
Once your set-up is successful, it is easy to install updated editions of Node. You can assess which versions are installed at the present moment with nvm Isand. When you want to observe which versions are obtainable to install, using nvm Is-remote.
Use nvm install #. #.#, for downloading, compiling & installing Node’s newer versions. You will apparently substitute the #’s for the version of Node you want.
You can notify nvm which edition to use in every new shell by using #.#.# after which you can set a default using an alias – nvm alias default- node.
Updating Node by Using a Package-Manager
Your second best option will be a package manager when nvm isn’t your choice. Npm or Node package manager assists you in discovering, using & sharing code, together with managing dependencies.
Npm is pre-installed in Node, whilst the package manager will be updated on a more frequent basis compared to Node.
To observe which edition you have, run npm –v after which npm will install npm@latest –g for the installation of the most current npm update.
When you want to see whether npm updated accurately, run npm –v once again.
You will need n nodule from npm, to be able to update Node. For clearing npm’s cache run this code; then install n, whilst installing the most recent stable edition of Node:
- sudo npm-cache clean –f
- sudo npm-install –g – n
- sudo n-stable
For installing the most recent release you will use n latest. As an alternative, run n #.#.# for getting a particular Node version.
Updating Node by Using Binary Packages (Ubuntu/Debian/Linux/CentOS)
In all honesty, this it not the route you want to go. However, it happens that one can get desperate. You can proceed to Node.js’s official downloads page and get the Linux binary file – 32-bit or 64-bit.
It is possible to download this file using a browser, although the console is preferable. Take into consideration that the particular Node version could change with the releasing of updates.
For unpacking the file, xz-utils will be required. For installing it, run: sudo apt-get install xz-utils. In your next step, use this code for installing the binary package within usr/local:
1 tar –C/usr/local –strip-components 1 –xJf node-v6.9.2-linux.x64.tar.xz
Now, having both Node and npm, you should consider giving option 2 a chance for updating the next version.
How to go about Updating Node Using Installers (Windows / macOS) on Nodejs.org
Node.js’s downloads page contains binary packages for macOS & Windows. The question is why would you want to complicate your life? The pre-prepared installers, for macOS – .pkg and for Windows – .msi make the procedure for installation highly efficient and comprehensive.
Download the file and then run it and then leave it to the installation wizard to handle the rest. With every update you will download, the most recent editions of both Node & npm will be replacing the older edition.
As an alternative, macOs-users can use the above-mentioned npm & n instructions.
Now your Node Update is completed; What about your Packages & Modules?
Updating Node & npm poses to be just the start. For maximizing both security and compatibility, keep the remainder of your dependencies and packages up to date.
You are having the most recent version of npm now and this article will lead you step by step to the end of this package update procedure.