Special offer
popup-offers
English
+370 5 205 5502 sales@monovm.com

How to Update Node.js

How to update Node.js? The steps vary among operating systems, and there are even different ways to do it on each. Learn how in today's article.

12 May, 21 by Antoniy Yushkevych 11 min Read

List of content you will read in this article:

Node.js has gained popularity due to its various advantages. Though other frameworks and languages offer benefits, Node.js has taken over web development among small and large enterprises. After the introduction of JavaScript, developers mostly preferred it due to its ubiquity in web development. JavaScript offers rich libraries for creating interactive and advanced interfaces but never deployed anything from the backend platform. However, Node.js comes as an alternative that multiple startups and enterprises have widely adopted.

Node.js has been introduced as a JavaScript runtime environment that helps build and run an infrastructure application. It provides a cross-platform and scalable way of executing the code. It is extremely efficient due to its event-driven I/O model.  Before moving forward to learn the different ways to update Node, we will get into the introduction of Node, its advantages, history, and various versions.

 

Node.js is a cross-platform JavaScript environment that allows server-side scripting. It ensures a non-blocking workflow thus making it popular amongst developers to create dynamic web-based applications.

Node.js provides a node package manager that is also known as npm. You can use its command-line feature that allows you to interact with the npm online repository for installing packages, version management, and dependency management. It is better to use the updated or the latest Node and npm to ensure improved performance and added functionalities.

Node.js is spreading its ways in creating real-time web-based applications, the Internet of Things, and managing microservices. It is being downloaded by over more than billions of developers and users globally. Due to its immense advantages, most developers are being adopted, and the skill is in great demand. 

The essential advantages of Node are mentioned below:

  • You can create real-time and high-traffic applications with great ease and efficiency.
  • You can use Node.js to build JavaScript code for both the client and server-side.
  • It enhances the development process efficiency as it bridges the gap between the frontend and backend developers.
  • Npm offers various tools and modules for the developers to use and helps in enhancing productivity.
  • It ensures that the code will run much faster than any other alternative language.
  • Use for running microservices, which is considered the perfect solution among enterprise applications.

You will definitely choose Node.js over other alternatives as it was developed for scalable applications. It provides a modern tooling solution and can create complex applications that stand apart from other languages.

 

Node.js has gained immense popularity. However, this language is just 12 years old compared to JavaScript (26 years old) and the Internet (32 years old). Node.js language was written in 2009 by Ryan Dahl, which he initially introduced for Mac OS X and Linux systems. Node.js was developed and maintained by Dahl, and after some time, it got sponsored by Joyent.

In 2009, Dahl strongly criticized the Apache HTTP server’s limited possibility for managing the thousands of multiple concurrent connections simultaneously. Due to the blocked code within the simultaneous connections process, it might have led to various issues; that could be resolved by creating a code through sequential programming.

Dahl demonstrated the Node.js project at the inaugural European JSConf for the first time on November 8, 2009. 

 

2009

  • The starting of Node.js
  • Creation of NPM (node package manager)

2010

  • The starting of Express
  • The starting of socket.io

2011

  • Released version 1.0 of npm
  • Adopted by companies Uber, LinkedIn, etc. 
  • The starting of hapi

2012

  • Node.js adoption continues and growing globally

2013

  • The first blogging platform using Node.js is Ghost. 
  • The starting of Koa

2014

  • IO.js became a significant fork of Node.js, known as “The Big Fork,” introduces the support for ES6 

2015

  • Foundation for Node.js began
  • IO.js is merged back into Node.js
  • Introduction of private npm modules

2016

  • The starting of Yarn
  • The advent of Node.js 6

2017

  • Security has become the main concern for npm focuses more on security. Node’s official download siteNode’s version manager
  • The introduction of Node.js 8 and HTTP/2
  • V8 introduces Node.js in its testing suite and making Node.js a target for the JS engine officially 

2018

  • The introduction of Node.js 10
  • ES modules .mjs experimental support

2019

  • The introduction of Node.js 12 - 13 version.
  • Started the work on Deno for moving server-side JS into the next decade, ensuring the modern JavaScript support

2020

  • The starting of Node.js 14 - 15
  • GitHub acquired npm

 

If you are working on Node.js, make sure you have Node.js’s latest version and packages installed on your system. In case you already have Node.js installed and want to upgrade it to the newest available stable version, you can follow the below steps. As Node.js is cross-platform, you can be installed on various platforms like Windows, Mac, and Linux. 

Below are the different ways to update Node.js to its latest version according to your system.

  • Update Node.js on Linux system
  • Update Node.js on Windows and macOS

Update Node.js on Linux system

You can adopt any of the three different ways of updating the Node.js version on a Linux-based system. 

Using NVM (Node Version Manager)

NVM is the practical tool that helps in managing the multiple versions of Node.js. You can update the version by following the below steps.

  • First, update the package repository using the following command.

sudo apt update

  • Then download the required dependencies by running the following command.

sudo apt install build-essential checkinstall libssl-dev

  • Now, run this command to download the NVM.

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

  • Restart the terminal by closing and opening it again.
  • Now you need to verify the success of the NVM installation using the command:

nvm --version

  • Before you update the Node.js version, check the existing version of your Node.js.

nvm ls

  • To check the newly available releases for Node.js, you can run the following command.

nvm ls-remote

  • You can now use the below command to install the latest version of Node.js, specifying the particular version.

nvm install [version.number]

Using NPM (Node Package Manager)

To update the Node.js, you can use the official package manager of Node. NPM is a tool that enables you to install and manage the dependencies of the Node package. Using the npm command will help you check the existing Node version and install the latest available release.  You can follow the below steps and commands for updating the Node.js version.

  • Before moving ahead, clear the cache of the NPM using the command:

npm cache clean -f

  • Using the following command, you can install the version manager for the Node, where n is the Node’s version manager.

npm install -g n

Using Binary Packages

This method is least preferred unless it is the only way left to update the version. You can follow the below-mentioned steps:

  • Navigate to the Node’s official download page, and you will find a list of available packages to download. You can either download the source code or a pre-built installer for the installation of the latest version.

  • If you are not comfortable with the above step for updating the version, then you can add the required version to the wget command mentioned below.

wget https://nodejs.org/dist/v12.13.1/node-v12.13.1-linux-x64.tar.xz

  • You can install the ‘xz-utils’ for extracting the binary package using the command:

sudo apt-get install xz-utils

  • You can run the following command to install the required package.

tar -C /usr/local –strip-components 1 -xJf node-v12.13.1-linux-x64.tar.xz

Update Node.js on Windows and macOS

You can follow the same ways for updating the Node version on Windows and macOS. There are two different ways to update the version.

  • Using installer
  • Using NPM

Using Installer

You can navigate to the official download site of the Node and install the latest version, as it will overwrite the existing version on your system. 

  • Visit the official site of Node.js for downloading and installing the latest stable version.

  • Once you decide which version to install, you can choose the required system (Windows or macOS) accordingly. The system will download and store the downloaded files in the specified directory.
  • After the completion of the downloading process, you can run the installer.
  • The Node.js prompt will open, and you can follow the steps.

  • Now, accept the license and click next to proceed.

  • You can fill in the path in the destination folder as per your choice where you want to install the Node.js.

  • Now select the way you want to install the Node feature and click next.

  • Now click install and start the installation process and then click finish.
  • Run the following command to check the installed version of Node.js.

node -v

Using NPM

Another way to update the Node version is using a command prompt with the npm command. The ‘n’ feature of Node.js allows you to interact with different versions of Node.js.

  • Before you update, check the existing Node.js version using the command:

node -v

  • Then, clear the cache using this command:

npm cache clean -f

  • Now install the ‘n’ globally using the command:

npm install -g n

  • Use the ‘n’ module for installing the latest stable version using any of the following commands.

sudo n stable

sudo n latest

n [version.number]

 

Node.js has been a popular language for creating web-based applications over the years. If you want to work with Node.js, you must use the latest stable version to experience new functionalities and make your web application more interactive. Updating Node.js to the latest version is not a cumbersome task and can be done in a few simple steps.

The above article will guide you through various steps for updating Node.js to its latest version on the different operating systems as per your project requirement. 

Antoniy Yushkevych

Master of word when it comes to technology, internet and privacy. I'm also your usual guy that always aims for the best result and takes a skateboard to work. If you need me, you will find me at the office's Counter-Strike championships on Fridays or at a.yushkevych@monovm.com