Node V 10 – The latest node.js upgrades and features

Node.js latest features in v10

The nodejs latest release was Node V 10. Almost in every six months, Node.js announces a major release by following a specific pattern. They cut the major release from the master branch.  Generally, in October, odd-numbered versions are replaced with the evenly numbered versions. Similarly, in April, the even-numbered version released.

If you’re searching for a dedicated server or hosting plan for the node.js development, we recommend you to spend some time in our node.js page to learn more about hosting and servers. We’re offering node.js cloud-based hosting and server with SSL certificate (necessity for latest HTTP/2 support) at an affordable price. The hosting and server include premium applications such as AspirationCDN, LiteSpeed Cache, and Patchman, etc. for better speed and security. Further, we guarantee pure SSD storage, dedicated cloud, web server powered by LiteSpeed, and 24/7 support on nodejs latest versions. Join us today for a 30% cut on the first-month invoice.

Mehedi Hossain Chowdhury for Aspiration Hosting

Nodejs latest features in V 10 – Stable HTTP/2

The HTTP/2 had been introduced by node.js on version 8.4.0 on a trial basis. But in the nodejs latest version, the HTTP/2 has become stable and a direct part of Node core.

What is HTTP/2?

HTTP/2 is a binary protocol powered by the TCP multiplexing. It means that all we need to connect the TCP once with the server. Later on, the server can reuse the existing connection. For example, the server can manage multiple requests and send the response by using the same connection. Further, it supports the server push option. Generally, server push handles the HTML request and send CSS or JavaScript as a response before the page loading ends. On another hand, the up to date versions of browsers is smart enough to realize that they have to send all request to render the site properly.

Features

Here note that the browsers only support HTTP/2 on SSL. Also, remember the SSL termination should be handled by the edge proxy. There is also Nginx that supports the HTTP/2 since its 1.13.9 release. But it is always better to put on edge proxy in front of the Node server. Because we don’t want to expose port 80 and 443. As we don’t want to process Node to operate as an admin. Further, in a similar way, we can configure the HTTP push and TLS termination without using the server code.

By using HTTP/2 in a microservice environment by ensuring proper security by DMZ, you can take all benefits of HTTP/2 straight from the Node process by exposing the Node server directly.

Right now, you can use the HTTP/2 with hapi and kao on experiment basis. But, the spdy module has full HTTP/2 support which also supports the Node Express. Either we can also use the express-http2-workaround module for HTTP/2 feature.

In most internet examples people suggest to use http2.createSecureServer but truly speaking you should let your edge proxy to handle such situations.

Nodejs latest  version 10 – ESM Modules

Though we can load multiple script files from HTML they cannot be considered as modules.  Because the objects are placed in a global namespace. In such a case, we can complete such operations using the module pattern which is not a convenient way. By using the ECMAScript modules the complexity dims a bit but not solved fully yet.

In the same note, Node.js is a framework and come with a module system named CommonJS. But the main issue is the two module systems are not suitable for each other. As a result, developers need to find a third way where they can build JS modules and later run can be used both in Node and browsers.

Nodejs latest  version 10 – Errors

In the earlier Node versions, the catch clauses were the only way to find an error by matching code. In that process, while handling errors user can only match the error message. But in case of error caused due to typing mistake you have to sweat to fix the bug. As many other codes are dependable upon the exact string shown in your error message.

But fortunately, in version 10 all errors shown by Node.js have a particular specific set of code. So, now we don’t need to bother to match the error message again and again.

Nodejs latest version 10 – Experimental Fs promises

The util.promisify in version 8 was able to easily wrap functions and provide a callback API. But in the latest version fs return functions return promises directly. Further, it eliminates the extra step and overhead likewise the previous versions.

Nodejs latest version 10 – N-API in Node 10

While switching versions of Node.js  the native modules always become a headache for the developers. In the earlier versions such as V8, the native modules were dependent on the V8/ NAN APIs. Such caused hazards like lack of API/ABI stability and also forced developers to update and recompile codes according to the new release.

Furthermore, the N-API includes abstraction layer on the V8/NAN. As a result, N-APIs are more stable and can be handled in a higher layer in contrast with the native add-ons. Until the release of Node V 10, this concept was in an experimental phase. But today, after the release of the nodejs latest version we’ll suggest our readers migrate N-API node either they already switched to the same.

However, the  N-API is a major change towards VM-diversity. Though the node.startedted their journey on Chrome’s V8, later it has been introduced to Microsoft ChakraCore. With the use of N-APIs, it becomes easier to create bindings among VMs. So, the porting Node.js to other runtimes became easier. In the next few years, who knows you might run Node.js on local machines – who knows?