{"id":233057,"date":"2021-04-22T15:00:21","date_gmt":"2021-04-22T12:00:21","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/whats-new-in-node-js-16-cloudsavvy-it\/"},"modified":"2021-04-22T15:00:21","modified_gmt":"2021-04-22T12:00:21","slug":"whats-new-in-node-js-16-cloudsavvy-it","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/whats-new-in-node-js-16-cloudsavvy-it\/","title":{"rendered":"#What\u2019s New In Node.js 16? \u2013 CloudSavvy IT"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a2fc2409fae1\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a2fc2409fae1\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/whats-new-in-node-js-16-cloudsavvy-it\/#JavaScript_Engine_Updates\" >JavaScript Engine Updates<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/whats-new-in-node-js-16-cloudsavvy-it\/#npm_v7\" >npm v7<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/whats-new-in-node-js-16-cloudsavvy-it\/#Other_Notable_Changes\" >Other Notable Changes<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/whats-new-in-node-js-16-cloudsavvy-it\/#Apple_Silicon\" >Apple Silicon<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/buradabiliyorum.com\/en\/whats-new-in-node-js-16-cloudsavvy-it\/#Deprecations\" >Deprecations<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/buradabiliyorum.com\/en\/whats-new-in-node-js-16-cloudsavvy-it\/#Summary\" >Summary<\/a><\/li><\/ul><\/nav><\/div>\n<p><strong>&#8220;#What\u2019s New In Node.js 16? \u2013 CloudSavvy IT&#8221;<\/strong><\/p>\n<div id=\"article-content-area\">\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1112\" data-pagespeed-lazy-src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2019\/07\/2350564e.png?width=1200&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"700\" height=\"300\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Node.js has launched its latest major version. Released in April 2021, <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/nodejs.medium.com\/node-js-16-available-now-7f5099a97e70\">v16 is the new<\/a> \u201ccurrent\u201d release. In October 2021, it will be promoted to the Long Term Support (LTS) release with maintenance continuing into 2024.<\/p>\n<p>The Node.js release process sees updates from the \u201ccurrent\u201d branch merged into the next major feature release. Consequently, v16 brings several recently added v15 features into what will eventually become the LTS branch. Although already available in v15, the changes are new to LTS users.<\/p>\n<h2 id=\"javascript-engine-updates\"><span class=\"ez-toc-section\" id=\"JavaScript_Engine_Updates\"><\/span>JavaScript Engine Updates<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Node.js 16 ships with v9.0 of the V8 Java<a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">Script<\/a> engine. This replaces V8 8.6 in Node.js 15. In the months between the two releases, V8 has landed several new features alongside significant performance enhancements.<\/p>\n<p>One such improvement is faster calls to functions with a mismatched argument list length. JavaScript permits you to pass a different number of arguments to the function\u2019s signature:<\/p>\n<div class=\"wp-geshi-highlight-wrap5\">\n<div class=\"wp-geshi-highlight-wrap4\">\n<div class=\"wp-geshi-highlight-wrap3\">\n<div class=\"wp-geshi-highlight-wrap2\">\n<div class=\"wp-geshi-highlight-wrap\">\n<div class=\"wp-geshi-highlight\">\n<div class=\"javascript\">\n<pre class=\"de1\"><span class=\"kw1\">function<\/span> demo<span class=\"br0\">(<\/span>a<span class=\"sy0\">,<\/span> b<span class=\"sy0\">,<\/span> c<span class=\"br0\">)<\/span> <span class=\"br0\">{<\/span>\n    <span class=\"co1\">\/\/ ...<\/span>\n<span class=\"br0\">}<\/span>\n\u00a0\n<span class=\"co1\">\/\/ OK<\/span>\ndemo<span class=\"br0\">(<\/span><span class=\"nu0\">1<\/span><span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span>\n\u00a0\n<span class=\"co1\">\/\/ Also OK<\/span>\ndemo<span class=\"br0\">(<\/span><span class=\"nu0\">1<\/span><span class=\"sy0\">,<\/span> <span class=\"nu0\">2<\/span><span class=\"sy0\">,<\/span> <span class=\"nu0\">3<\/span><span class=\"sy0\">,<\/span> <span class=\"nu0\">4<\/span><span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>The first variant is commonly used when a parameter is optional. The latter variant sometimes occurs when a function is refactored to remove an argument. This kind of code incurred a performance penalty prior to V8 8.7. Reworking the internals used to handle mismatched argument list lengths has <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/v8.dev\/blog\/v8-release-89\">virtually eliminated<\/a> the overhead.<\/p>\n<p>Another performance improvement concerns the <code>super<\/code> property. This JavaScript feature lets you access the parent of a class that\u2019s using inheritance. Calls to <code>super<\/code> used to be unoptimised, incurring a runtime call on each use. V8 v9 shipped changes enabling <code>super<\/code> property access <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/v8.dev\/blog\/fast-super\">to execute orders of magnitude<\/a> more quickly. This optimisation is now available to Node.js users.<\/p>\n<p>Finally, V8 v9 comes with a significant new feature for regular expressions. You can now request an array containing the start and end positions of each matched capture group. This is enabled using the <code>\/d<\/code> flag with <code>RegExp<\/code>. You can then access the indices array via the <code>indices<\/code> property of the execution result object.<\/p>\n<div class=\"wp-geshi-highlight-wrap5\">\n<div class=\"wp-geshi-highlight-wrap4\">\n<div class=\"wp-geshi-highlight-wrap3\">\n<div class=\"wp-geshi-highlight-wrap2\">\n<div class=\"wp-geshi-highlight-wrap\">\n<div class=\"wp-geshi-highlight\">\n<div class=\"javascript\">\n<pre class=\"de1\"><span class=\"kw1\">const<\/span> regex <span class=\"sy0\">=<\/span> <span class=\"sy0\">\/<\/span><span class=\"br0\">(<\/span>a<span class=\"br0\">)<\/span><span class=\"br0\">(<\/span>b<span class=\"br0\">)<\/span><span class=\"sy0\">\/<\/span>d<span class=\"sy0\">;<\/span>\n<span class=\"kw1\">const<\/span> match <span class=\"sy0\">=<\/span> regex.<span class=\"me1\">exec<\/span><span class=\"br0\">(<\/span><span class=\"st0\">\"xy\"<\/span><span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span>\n\u00a0\nconsole.<span class=\"me1\">log<\/span><span class=\"br0\">(<\/span>match.<span class=\"me1\">indices<\/span><span class=\"br0\">[<\/span><span class=\"nu0\">0<\/span><span class=\"br0\">]<\/span><span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span>      <span class=\"co1\">\/\/ [0, 2]<\/span>\nconsole.<span class=\"me1\">log<\/span><span class=\"br0\">(<\/span>match.<span class=\"me1\">indices<\/span><span class=\"br0\">[<\/span><span class=\"nu0\">1<\/span><span class=\"br0\">]<\/span><span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span>      <span class=\"co1\">\/\/ [0, 1]<\/span>\nconsole.<span class=\"me1\">log<\/span><span class=\"br0\">(<\/span>match.<span class=\"me1\">indices<\/span><span class=\"br0\">[<\/span><span class=\"nu0\">2<\/span><span class=\"br0\">]<\/span><span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span>      <span class=\"co1\">\/\/ [1, 2]<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>The first item in the array represents the entire match. The subsequent elements give you the positions of each matched capture group in the input string.<\/p>\n<h2 id=\"npm-v7\"><span class=\"ez-toc-section\" id=\"npm_v7\"><\/span>npm v7<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Node.js v16 will introduce npm v7 to the LTS channel. npm underwent a substantial internal refactoring to improve performance and overhaul the peer dependencies workflow.<\/p>\n<p>Peer dependencies are now installed automatically alongside regular dependencies. This might be a breaking change in some workflows, although disruption\u2019s <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/github.blog\/2020-10-13-presenting-v7-0-0-of-the-npm-cli\">\u201cusually minimal.\u201d<\/a><\/p>\n<p>There\u2019s also a new format for <code>package-lock.json<\/code> which enables more reliable deterministic builds. It now includes <em>everything<\/em> npm needs to rebuild your package tree from scratch. If you\u2019re migrating from Yarn, npm\u2019s gained support for <code>yarn.lock<\/code> files too.<\/p>\n<h2 id=\"other-notable-changes\"><span class=\"ez-toc-section\" id=\"Other_Notable_Changes\"><\/span>Other Notable Changes<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>v16 promotes the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/nodejs.org\/api\/timers.html\">Timers Promises API<\/a> to stable status. This API provides JavaScript timer functions that return native promises. Functions such as <code>setTimeout()<\/code> usually accept a callback. This can be unwieldy when used with modern asynchronous code.<\/p>\n<div class=\"wp-geshi-highlight-wrap5\">\n<div class=\"wp-geshi-highlight-wrap4\">\n<div class=\"wp-geshi-highlight-wrap3\">\n<div class=\"wp-geshi-highlight-wrap2\">\n<div class=\"wp-geshi-highlight-wrap\">\n<div class=\"wp-geshi-highlight\">\n<div class=\"javascript\">\n<pre class=\"de1\"><span class=\"co1\">\/\/ Old<\/span>\n<span class=\"kw1\">function<\/span> demoOld<span class=\"br0\">(<\/span><span class=\"br0\">)<\/span> <span class=\"br0\">{<\/span>\n    setTimeout<span class=\"br0\">(<\/span><span class=\"br0\">(<\/span><span class=\"br0\">)<\/span> <span class=\"sy0\">=&gt;<\/span> <span class=\"br0\">{<\/span>\n        console.<span class=\"me1\">log<\/span><span class=\"br0\">(<\/span><span class=\"st0\">\"Timer expired.\"<\/span><span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span>\n    <span class=\"br0\">}<\/span><span class=\"sy0\">,<\/span> <span class=\"nu0\">5000<\/span><span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span>\n<span class=\"br0\">}<\/span>\n\u00a0\n<span class=\"co1\">\/\/ New<\/span>\n<span class=\"kw5\">import<\/span> <span class=\"br0\">{<\/span>setTimeout<span class=\"br0\">}<\/span> from <span class=\"st0\">\"timers\/promises\"<\/span><span class=\"sy0\">;<\/span>\nasync <span class=\"kw1\">function<\/span> demoNew<span class=\"br0\">(<\/span><span class=\"br0\">)<\/span> <span class=\"br0\">{<\/span>\n    await setTimeout<span class=\"br0\">(<\/span><span class=\"nu0\">5000<\/span><span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span>\n    console.<span class=\"me1\">log<\/span><span class=\"br0\">(<\/span><span class=\"st0\">\"Timer expired.\"<\/span><span class=\"br0\">)<\/span><span class=\"sy0\">;<\/span>\n<span class=\"br0\">}<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>Using promises makes for more readable code when combined with <code>async<\/code>\/<code>await<\/code>. Waiting for a timer feels like a traditional <code>sleep<\/code> call in a synchronous language.<\/p>\n<p>Node.js has also added experimental support for the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.w3.org\/TR\/WebCryptoAPI\">Web Crypto API<\/a>. This W3C specification is intended to give web applications access to an elementary set of cryptographic functions. The API offers hash generation and signature verification alongside encryption and decryption utilities.<\/p>\n<p>Offering Web Crypto support in Node.js improves interoperability between JavaScript on servers and JavaScript in web browsers. The Node implementation <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/nodejs.org\/api\/webcrypto.html#webcrypto_node_js_specific_extensions\">extends various aspects<\/a> of the W3C spec and includes its own variations of some objects.<\/p>\n<h2 id=\"apple-silicon\"><span class=\"ez-toc-section\" id=\"Apple_Silicon\"><\/span>Apple Silicon<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>A change that\u2019s completely new in v16 is the publication of builds for Apple Silicon processors. This should improve performance on new Mac hardware. Node.js will run natively on the Apple M1, instead of using the Rosetta emulation layer.<\/p>\n<p>Users installing via the tarball distribution mechanism will need to choose between <code>darwin-x64<\/code> (Intel) or <code>darwin-amd64<\/code> (Apple Silicon) packages. If you use the macOS install utility, a single download with support for both architectures is provided.<\/p>\n<h2 id=\"deprecations\"><span class=\"ez-toc-section\" id=\"Deprecations\"><\/span>Deprecations<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Being a major release, v16 comes with some deprecations and removals. You can find the full list in <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/github.com\/nodejs\/node\/blob\/master\/doc\/changelogs\/CHANGELOG_V16.md#16.0.0\">the complete changelog<\/a>.<\/p>\n<p>A notable deprecation is the intent to remove access to several core modules via <code>process.binding()<\/code>. This call provides a mechanism to access the underlying C++ objects behind the Javacript implementation of modules. Bindings for modules including <code>crypto<\/code>, <code>v8<\/code>, <code>async_wrap<\/code> and <code>url<\/code> have been deprecated and could be removed in the future.<\/p>\n<p>Elsewhere, the <code>recursive<\/code> option to the <code>fs.rmdir()<\/code> directory removal function has been deprecated. New code should use the alternative <code>fs.rm(path, {recursive: true})<\/code> function instead. This change has been made to better align Node.js with the <code>rmdir<\/code> Unix command and <code>rmdir()<\/code>-equivalent functions in other programming languages.<\/p>\n<h2 id=\"summary\"><span class=\"ez-toc-section\" id=\"Summary\"><\/span>Summary<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Node.js v16 is a major new release which will bring several new features to the LTS channel while rolling the latest V8 JavaScript features. This comes alongside npm v7 and the launch of Apple Silicon-native builds.<\/p>\n<p>You can get the new release via the current channel by following the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/nodejs.org\/en\">installation docs<\/a> on the Node.js website. v16 will replace v14 as the LTS release on October 26th, 2021.<\/p>\n<p>The current Node.js v15 release will remain supported until June 1st, 2021. Users should look to upgrade to v16 as soon as possible. The currently active LTS branch, v14, will be maintained through the end of April 2023.\n<\/p><\/div>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.cloudsavvyit.com\/10779\/whats-new-in-node-js-16\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#What\u2019s New In Node.js 16? \u2013 CloudSavvy IT&#8221; Node.js has launched its latest major version. Released in April 2021, v16 is the new \u201ccurrent\u201d release. In October 2021, it will be promoted to the Long Term Support (LTS) release with maintenance continuing into 2024. The Node.js release process sees updates from the \u201ccurrent\u201d branch merged&#8230;<\/p>\n","protected":false},"author":1,"featured_media":233058,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2019\/07\/2350564e.png","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-233057","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/233057","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=233057"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/233057\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/233058"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=233057"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=233057"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=233057"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}