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 LTS v10.13.
What’s new with Node.js 10?
As the release schedule suggests, October is typically a busy time of year for the Node.js team. Each LTS version receives 30 months of support which will land in April of the target year. This is also when the maintenance LTS cycle starts for the next planned Node.js LTS version. Another important factor to keep in mind is that even-numbered releases (i.e. 6, 8, 10) are LTS, whereas odd-numbered releases are current versions which receive a 6-month support timeline.
Main features of Node.js LTS version 10.13.0
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.
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.
How to upgrade to Node.js 10 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
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 10.13.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 11.
Do I need to upgrade to Node.js 10?
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. To give a deeper perspective into the timeline, the team will support Node.js version 8 LTS until April 2019, with its lifecycle ending in December of 2019.