Node.js Becomes the Latest Node.js LTS Version | Should You Upgrade?

Life as a developer just got a little bit easier as Node.js 10, codename “Dubnium” becomes the current LTS (Long Term Support, or “stable”) Node.js version of the popular framework. For those who are more interested in exploring the latest features in a local environment, Node.js 11 will also be set to the current (otherwise known as the unstable) release. Now let’s gain more insight into the performance upgrades brought by Node.js.

How to upgrade to Node.js from a previous version using npm

Now that Node.js version 10 is LTS, it is safe to upgrade within production environments (and also recommended).

Once deciding you’d like to update your version, first check to see that you have the latest version of the package manager using the command npm -v.

Then, to update npm simply run npm install [email protected] -g. The latest option executes exactly what you’d imagine it would by installing the latest version. The “g” option tells the system to install the update globally.

Once this process is complete, you can upgrade node using the same commands. First, check on your current version of node, type the command

node -v

If you are upgrading your application from the previous Node.js LTS version, it will likely display a variation of v8. To start, we’ll need the npm’ n module which is used for Node.js version management. To install the latest stable release of Node, type in the following commands:

sudo npm cache clean -f

sudo npm install -g n

Like npm, this will install the n module globally. We can then install the latest stable version of node.

sudo n stable

Alternatively, if you’d like to update node to a specific version you can use the command n #.#.#. (i.e, n 15.04.0). You can also use the command n latest to simply install the latest version of Node. In this case, that would be Node.js 15.

Do I need to upgrade to Node.js?

Fortunately, the process of upgrading (or even downgrading) a Node.js version is incredibly simple. Going through the aforementioned process upgrades Node as if it were never there in the first place, allowing all its properties to work seamlessly. So is it necessary to upgrade to the latest LTS immediately? The answer is both yes and no.

Developers who are eager to explore new features and bring in performance improvements to their applications may seek to upgrade immediately. And given the ease of the installation process, upgrading typically causes no harm within the node environment. In fact, search results return little to no stories mentioning an upgrade breaking any libraries. However, for those that are more reserved may prove to be more reluctant to upgrading.

Deploy your Node.js App

Main features of previous Node.js LTS version 10.13.0

The latest updates to the Node.js infrastructure were focused primarily on performance improvements, security updates, and JavaScript features to name a few.

1) The Node Package Manager

Node.js LTS v10 will include npm version 6.4 (released August 15th, 2018) which is set to bring performance improvements over previous versions.

2) Equipped with the latest Chrome JavaScript Engine

The newest LTS is also equipped with the v8 JavaScript engine. For those that are unfamiliar, The Chromium Project’s v8 is an open source JavaScript and WebAssembly engine which compiles JavaScript to native machine code before executing it. The engine will also dynamically optimize the code at runtime, offering greater improvements in performance and Chrome Dev Tool diagnostics to Node.js users. As mentioned previously, enhancements in performance and diagnostic capability was a priority in Node 10 development.

3) HTTP/2 is here

HTTP/2 is no longer experimental and now a stable part of Node.js 10. It seeks to improve latency, minimize protocol overhead, and add support for server push. The latency improvements come in the form of multiplexing, which reduces the number of requests, immediately responding with the requested assets, as opposed to serving files individually. Coupled with server push, which allows the server to send assets before the request is even implemented, HTTP/2 shows significant increases in performance over the existing protocol.

Here is a snippet of code implementing server push from this Rising Stack blog post.

Here we can see the code explicitly states which files to send to the browser before the client requests them.

Also Read: How to Set Up a Node.js Server on a Linux VPS

Host a Node.js Server

Share this post with your friends