Update: You may now read our rundown of Node.js 20, where we are going through all the new features, breaking changes, and more. The post is available under this link.
Summary
There are few tools that can even match the overwhelming enthusiasm for Node.js. It’s a safe foundation for so many services from so many industries: including the traditional bastions of Java and C#, such as fintech or banking.
On April 19th, the team behind Node.js decided to release another major update to the JavaScript tool – Node.js 18. We will take a look at what changes arrived with the upgrade, and what they mean to businesses around the world. We have also asked one of our Node.js specialists, Artur Łabudziński, what he thinks about the newest version of Node. He responded with this quote:
It's great to see that the team removed type coercion in some functions – it will make development easier for sure.
Upgrading the V8 engine to version 10.1 [the same one that powers Chrome 101] brings many new benefits to the whole JavaScript ecosystem; from adding new features to major performance optimizations. I'm always impressed by the work that the V8 team puts in speeding up their engine.
Unfortunately, regardless of whether new releases are out there, some cloud providers lag behind others. AWS is one example, supporting only Node 14, when we have Node 18. The decision to start supporting versions 16+ would be a great one.
Let’s dig in!
In case you aren’t aware of the biggest advantages of Node.js and its languages: JavaScript and TypeScript, then a few of the most important ones are:
We covered this topic a few times already: in case you want everything in one place, feel free to download our comprehensive guide on JavaScript, TypeScript, and Node.js, in the form of a free e-book, here.
Going back to the most notable features of the newest version of Node.js:
A Node functionality, borrowed from browser-side JavaScript, is the new fetch function: something that let you connect to servers; it allowed you to transfer data to and from that server of choice.
The new fetch function is something that developers could do beforehand, though they often opted into installing third-party packages to achieve this. That, in turn, introduced a ton of 3rd party code to the project. In settings where safety is a number one priority, it was, at the very least, problematic and undesired. We now also have a single, standardized way to make HTTP requests across all JavaScript platforms.
The newly introduced function is, to simplify it, heavily based on undici, a piece of code written especially to fill the fetch-shaped gap in Node.js. The major con that the majority of developers and tech managers will want to know about is that the implementation is notoriously slow. It’s more than a hundred times slower than its younger sibling Deno’s implementation.
Even though it enables easier reusing of JavaScript between browsers and Node, the sluggishness is a concern. While it is not a big issue for the majority of companies, some do want to squeeze “world record times” out of every function. They will have to rely on the old ways of doing things.
Testing is elementary for creating quality products. Until now, we did not have a built-in test runner for Node. That is changing, with the team introducing a test runner available out of the box.
Whether this is as a response to some voices in the community saying Node.js does not provide much out of the box or not, it’s absolutely something that new teams will appreciate. The older teams probably already have a testing framework in place.
The new tool should feel familiar to many Node.js & front-end developers alike. An example test looks like this:
If you have worked on a JavaScript or a TypeScript project, you know what this code does. It could be a continuation of the effort to bring Node.js APIs closer to the browser ones (as much as it makes sense).
V8 is the name of the tech that powers JavaScript’s powerhouse. It’s also the same tech that Chrome uses to run web apps. As such, the team responsible for this critical part of Chrome works hard on improvements to V8, that would allow them to significantly beat Firefox’s alternative. The JavaScript engine, with an engine-themed name, is now the same one that powers Chrome 101. With it, came concrete performance improvements. Some of them were massive.
Node.js users are particularly happy about that (or could be), since they are getting performance improvements to their apps for free. You are not changing a thing about your app, and yet it will run faster and provide developers with more options, assuming your app is compatible. Speaking of compatibility…
As with each major upgrade, also this time there are some changes that will force you to change your app a bit. This time there are also little changes like that. Two of them pertain to the availability.
To be more precise, Node.js is now “experimental” on the 32-bit Windows platform, and the minimum required version of macOS is now 10.15. If you are one of the people who started looking up “macOS 10.14 Node 18 not working” or “32-bit Windows Node 18 download” in a disarray, then there is no other option than to change your operating system. The case is similar for some Linux distributions. If you are an Ubuntu, Debian, or Red Hat Enterprise Linux user, then you need to upgrade to versions 20.04, 10, and 8 respectively as well. Progress brings changes we do not wish for, occasionally, but the ones that we need to get through.
To end this section, there are additional modifications that may break your apps, that we did not cover. We did it so that we don’t write an entire e-book worth of content every time a popular tool has a new release.
Node.js shook up the world of enterprise IT in a way nobody expected it to. It turned JavaScript from an ugly duckling to a beautiful swan and became one of the rulers of back-ends in a story that is full of twists and turns with a happy ending.
Crucially, Node.js 18 will gain the Long-Term-Support (LTS) status later this year (2022). The development team of the popular tool will support it until 2025. Should you migrate onto version 18 now, you will have three years of peace of mind. In case your app is too big to easily migrate, and you need help, or if you are building web apps with Node.js in mind, don’t hesitate to get in touch.