{"componentChunkName":"component---src-pages-index-js","path":"/","result":{"data":{"contentfulPage":{"hero":{"headLine":"Your latest Node.js content, news and updates in one place.","coverImage":{"file":{"fileName":"social-bg-12 (1)-min.png","url":"//images.ctfassets.net/xmu5vdhtphau/1ZgP9Kv0C8g1nuEX3zTs2a/f00ee931ce94307ccf8a62c17d3d67d2/social-bg-12__1_-min.png"}}},"blogs":[{"slug":"choosing-the-right-node-js-framework-next-nuxt-nest","title":"Choosing the right Node.js Framework: Next, Nuxt, Nest?","createdAt":"May 30, 2020","author":{"name":"Liz Parody"},"image":{"file":{"url":"//images.ctfassets.net/xmu5vdhtphau/2Zac9uxugtE8AunstNN6ip/cbc4b669fc07fb954bc870f756f08dfc/24-min.jpg","fileName":"24-min.jpg"}},"bodyContent":{"childMarkdownRemark":{"html":"<p>In my previous blog post, I explored the differences, advantages, and disadvantages of three of the most popular Node.js frameworks: <a href=\"https://nodesource.com/blog/Express-Koa-Hapi\">Express, Koa, and Hapi</a>. In this blog post, I’m going to examine the differences between three more very popular frameworks: Next, Nuxt, and Nest. These three frameworks are server-side rendering, and they are closely related to React, Vue, and Angular (the three most widely used front-end frameworks), respectively.</p>\n<ul>\n<li>\n<p>The comparison is based on:</p>\n<ul>\n<li>Popularity (GitHub Stars and npm downloads).</li>\n<li>Installation.</li>\n<li>Basic Hello World app.</li>\n<li>Advantages.</li>\n<li>Disadvantages.</li>\n<li>Performance.</li>\n<li>Community involvement.</li>\n</ul>\n</li>\n</ul>\n<h1>Next</h1>\n<ul>\n<li><a href=\"https://github.com/zeit/next.js/\">GitHub Stars: +36,000</a></li>\n<li><a href=\"https://www.npmjs.com/package/next\">npm weekly downloads: +300,000</a></li>\n</ul>\n<p>Next is the most popular framework compared to the other two. It has more npm weekly downloads, GitHub stars and number of contributors.</p>\n<p>Next.js is a React framework that lets you build server-side rendering and static web applications using React.</p>\n<h3>Installation</h3>\n<p>Install it:</p>\n<pre><code>npm install --save next react react-dom\n</code></pre>\n<p>and add a script to your package.json like this:</p>\n<pre><code>{\n  \"scripts\": {\n    \"dev\": \"next\",\n    \"build\": \"next build\",\n    \"start\": \"next start\"\n  }\n}\n</code></pre>\n<p>After that, the file-system is the main API. Every .js file becomes a route that gets automatically processed and rendered.</p>\n<h3>Basic Hello World app</h3>\n<p>Populate <code>./pages/index.js</code> inside your project:</p>\n<pre><code>function Home() {\n  return &#x3C;div>Hello world!&#x3C;/div>;\n}\n\nexport default Home;\n</code></pre>\n<p>Then just run <code>npm run dev</code> and go to <code>http://localhost:3000</code>. To use another port, you can run <code>npm run dev -- -p &#x3C;your port here></code>.</p>\n<h3>Advantages</h3>\n<ul>\n<li>Every component is server-rendered by default</li>\n<li>Automatic code splitting for faster page loads </li>\n<li>Unnecessary code is not loaded</li>\n<li>Simple client-side routing (page-based)</li>\n<li>Webpack-based dev environment which supports Hot Module Replacement (HMR)</li>\n<li>Fetching data is very simple</li>\n<li>Can be implemented with Express or any other Node.js HTTP server</li>\n<li>It’s possible to customize with your own Babel and Webpack configurations</li>\n<li>Easy to deploy anywhere if Node.js is supported</li>\n<li>Built-in handling of search engine optimization (SEO) for pages </li>\n</ul>\n<h3>Disadvantages</h3>\n<ul>\n<li>Next.js is not backend; if you need backend logic, such as a database or an accounts server, you should keep that in a separate server application</li>\n<li>Next is powerful, but If you’re creating a simple app, it can be overkill</li>\n<li>All data needs to be loadable from both the client and server</li>\n<li>Migrating a server-side app to Next.js is not a quick process, and depending on your project it may be too much work</li>\n</ul>\n<h3>Performance</h3>\n<p>To measure the performance, I used <a href=\"https://httpd.apache.org/docs/2.4/programs/ab.html\">Apache Bench</a> for benchmarking, which highlights how many requests per second the app is capable of serving.  I also used <a href=\"https://developers.google.com/web/tools/lighthouse/\">lighthouse</a> to audit performance, accessibility, best practices, and SEO.</p>\n<p><img src=\"//images.ctfassets.net/hspc7zpa5cvq/5gcP7k5WIw7h4mSYuZIDMq/898ad62724d65c969e60d305e1e85d2e/next.png\" alt=\"next\"></p>\n<p>This is a basic Hello World app in Next.js. It handles 550.87 requests per second. This value is the result of dividing the number of requests by the total time taken. The average time spent per request is 18.153 ms. </p>\n<p>Compared to the other two frameworks, Next.js scored better overall than Nuxt.js but worse than Nest.js</p>\n<p><img src=\"//images.ctfassets.net/hspc7zpa5cvq/6SWp0mED1Nb9fXIBM7WwXC/4982654aa94d5d89fc6a0053b1ed90d1/next1.png\" alt=\"next1\"></p>\n<p>In the report provided by lighthouse, we can see that the performance, accessibility, best practices, and SEO scores are all above 70, which is good, but compared with the other two frameworks, it had the lowest score for  Performance and has the highest score in Best Practices. </p>\n<h3>Community involvement</h3>\n<ul>\n<li><a href=\"https://github.com/zeit/next.js/graphs/contributors\">Number of contributors: 678</a></li>\n<li><a href=\"https://github.com/zeit/next.js/pulls\">Closed Pull Requests: 3,029</a></li>\n</ul>\n<p>The Next.js community communicates through <a href=\"https://spectrum.chat/next-js?tab=posts\">chat</a>, <a href=\"https://zeit.co/chat\">slack</a>, issues and pull request on <a href=\"https://github.com/zeit/next.js\">GitHub</a>.</p>\n<p>Also, in the repo <a href=\"https://github.com/unicodeveloper/awesome-nextjs\">awesome-nextjs</a>, there is a list of essentials, articles, boilerplates, extensions, apps, books, and videos that are useful for developers using Next.js</p>\n<h1>Nuxt</h1>\n<ul>\n<li><a href=\"https://github.com/nuxt/nuxt.js\">GitHub Stars: +19,000</a></li>\n<li><a href=\"https://www.npmjs.com/package/nuxt\">npm weekly downloads: +100,000</a></li>\n</ul>\n<p>Nuxt is a Vue.js Meta Framework to create complex, fast, and universal web applications quickly.</p>\n<h3>Installation</h3>\n<p>Install it:</p>\n<pre><code>$ npm i nuxt\n</code></pre>\n<p>To create a basic app:</p>\n<pre><code>$ npx create-nuxt-app &#x3C;project-name>\n</code></pre>\n<p>You can start directly with the CLI <a href=\"https://github.com/nuxt-community/create-nuxt-app\">create-nuxt-app</a> for the latest updates.\nOr you can start by using one of the starter templates:\n<a href=\"https://github.com/nuxt-community/starter-template\">starter</a>: Basic Nuxt.js project template\n<a href=\"https://github.com/nuxt-community/express-template\">express</a>: Nuxt.js + Express\n<a href=\"https://github.com/nuxt-community/koa-template\">koa</a>: Nuxt.js + Koa\n<a href=\"https://github.com/nuxt-community/adonuxt-template\">adonuxt</a>: Nuxt.js + AdonisJS\n<a href=\"https://github.com/nuxt-community/micro-template\">micro</a>: Nuxt.js + Micro\n<a href=\"https://github.com/nuxt-community/nuxtent-template\">nuxtent</a>: Nuxt.js + Nuxtent module for content heavy sites</p>\n<h3>Basic Hello World app</h3>\n<p>This is the most basic example of a <a href=\"https://nuxtjs.org/examples/\">“Hello World!”</a> app on Nuxt:</p>\n<pre><code>&#x3C;template>\n  &#x3C;div>\n    &#x3C;h1>Hello world!&#x3C;/h1>\n    &#x3C;NLink to=\"/about\">\n      About Page\n    &#x3C;/NLink>\n  &#x3C;/div>\n&#x3C;/template>\n\n&#x3C;script>\nexport default {\n  head: {\n    title: 'Home page'\n  }\n}\n&#x3C;/script>\n</code></pre>\n<h3><a href=\"https://medium.com/vue-mastery/10-reasons-to-use-nuxt-js-for-your-next-web-application-522397c9366b\">Advantages</a></h3>\n<ul>\n<li>Its main scope is UI rendering, while abstracting away the client/server distribution</li>\n<li>Statically render your Vue apps and get all of the benefits of a universal app without a server</li>\n<li>Get automatic code splitting (pre-rendered pages)</li>\n<li>Setup via the command line with the starter template</li>\n<li>Get great project structure by default</li>\n<li>Easily set up transitions between your routes and write single file components</li>\n<li>Get ES6/ES7 compilation without any extra work</li>\n<li>Get set up with an auto-updating server for easy development</li>\n<li>Powerful Routing System with Asynchronous Data</li>\n<li>Static File Serving</li>\n<li>ES6/ES7 Transpilation</li>\n<li>Hot module replacement in Development</li>\n<li>Pre-processor: Sass, Less, Stylus, etc.</li>\n</ul>\n<h3>Disadvantages</h3>\n<ul>\n<li>It has a smaller community, which means fewer resources and potentially less extensive documentation</li>\n<li>Lack of some common solid plugins/components. (Google maps, calendar, vector maps). Some components for that exist, but they are generally not very well maintained.</li>\n<li>It is necessary to go deep in more complex components/plugins. If you want to develop something very flexible, you have to get down to render functions/jsx to do that. (e.g render the contents of a slot in another place/component).</li>\n<li>Props have to be specified explicitly. There might be cases when you want to transform some CSS classes to props;  you’ll have to specify these props or use $attrs / render functions or jsx.</li>\n<li>Reactivity caveats like setting an item from an array directly <code>this.items[key]=value</code> or adding a new data property. </li>\n<li>High traffic may put strain on your server</li>\n<li>You can only query and manipulate the DOM in certain hooks</li>\n</ul>\n<h3>Performance</h3>\n<p><img src=\"//images.ctfassets.net/hspc7zpa5cvq/77aAB8VVmQi8Kif9gTCQ4U/2fd522c337487dce659994e37e8edbeb/nuxt.png\" alt=\"nuxt\"></p>\n<p>This is a basic Hello World app in Nuxt.js. It handles 190.05 requests per second. The average time spent per request is 52.619 ms. On this metric, Nuxt.js performs the worst compared to the other two frameworks.</p>\n<p><img src=\"//images.ctfassets.net/hspc7zpa5cvq/7hS5nyqzb8UAFd9NidP5sQ/e0cf7d7936142535c0c8aedaad038d81/nuxt1.png\" alt=\"nuxt1\"></p>\n<p>Nuxt.js has the highest score in three of the four measures; performance, accesibility and SEO. </p>\n<h3>Community involvement</h3>\n<ul>\n<li><a href=\"https://github.com/nuxt/nuxt.js/graphs/contributors\">Number of contributors: 191</a> </li>\n<li><a href=\"https://github.com/nuxt/nuxt.js/pulls\">Closed Pull Requests: 1,385</a></li>\n</ul>\n<p>There is a <a href=\"https://github.com/nuxt-community\">GitHub organization</a> where you can find modules and projects from the Nuxt.js community. There is also a curated list of awesome things related to Nuxt.js <a href=\"https://github.com/nuxt-community/awesome-nuxt\">awesome-nuxt</a> including Modules, tools, mention of Nuxt.js, showcase, tutorials, blogs, books, starter template, official examples, and projects using Nuxt.js.</p>\n<p>The community communicates through <a href=\"https://gitter.im/nuxt/nuxt.js\">Gitter Chat Room</a>, <a href=\"https://t.me/nuxtjs_ru\">Telegram, Russian community</a>, <a href=\"https://discordapp.com/invite/VApZF5W\">Discord</a>, <a href=\"https://twitter.com/nuxt_js\">Twitter</a> and <a href=\"https://www.youtube.com/channel/UCJ9jj5YMzo-HsyM6WG9Q_Lg\">YouTube Channel</a> </p>\n<h1>Nest</h1>\n<ul>\n<li><a href=\"https://github.com/nestjs/nest\">GitHub Stars: +14,000</a></li>\n<li><a href=\"https://www.npmjs.com/package/@nestjs/core\">npm weekly downloads: +122,000</a></li>\n</ul>\n<p>A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications on top of TypeScript and JavaScript (ES6, ES7, ES8), Nest is heavily inspired by Angular. </p>\n<p>Nest is a framework for building efficient, scalable Node.js server-side applications. It uses modern JavaScript, is built with TypeScript (preserves compatibility with pure JavaScript) and combines elements of OOP (Object Oriented Programming), FP (Functional Programming), and FRP (Functional Reactive Programming).</p>\n<p>Under the hood, Nest makes use of Express, but also provides compatibility with a wide range of other libraries, like e.g. Fastify, allowing for easy use of the myriad third-party plugins which are available.</p>\n<h3>Installation</h3>\n<p>Install it:</p>\n<pre><code>$ npm i @nestjs/cli\n$ nest new project-name\n</code></pre>\n<p>Alternatively, to install the TypeScript starter project with Git:</p>\n<pre><code>$ git clone https://github.com/nestjs/typescript-starter.git project\n$ cd project\n$ npm install\n$ npm run start\n</code></pre>\n<h3>Basic Hello World app</h3>\n<p>After installing Nest.js with the <code>npm cli</code> command, and creating a new project with <code>nest new project-name</code>, a <code>src/</code> directory will be created and populated with several core files, including <code>main.ts</code>.\nThe <code>main.ts</code> includes an async function, which will bootstrap our application:</p>\n<pre><code>import { NestFactory } from '@nestjs/core';\nimport { ApplicationModule } from './app.module';\n\nasync function bootstrap() {\n  const app = await NestFactory.create(ApplicationModule);\n  await app.listen(3000);\n}\nbootstrap();\n</code></pre>\n<p>And then to run the app that listens on port 3000, you execute: </p>\n<pre><code>$ npm run start\n</code></pre>\n<h3><a href=\"https://medium.com/@jtearl188/what-is-nest-js-and-should-i-use-it-b71c7646926b\">Advantages</a></h3>\n<ul>\n<li>As a TypeScript-based web framework, strict type definition is possible</li>\n<li>The framework is very annotation-driven, with everything from endpoints to Swagger documentation being generated from them. The endpoints are clean and simple, and the annotations make developing simpler all around.</li>\n<li>The folder structure in Nest.js is heavily based on Angular. This allows for minimal downtime when first designing a Nest service.</li>\n<li>Because Nest.js is a module-based framework, it’s easyto externalize general-purpose modules and reuse code in multiple projects</li>\n<li>Components get their own folders, with an application module and main file residing in the root. This simple structure allows more attention to be paid to the design of endpoints and their consumers, instead of application structure.</li>\n<li>Nest.js uses the latest version of TypeScript, which helps ensure that it will remain relevant in the rapidly changing JavaScript landscape and gives developers less context switching. The transition from Angular code to Nest is relatively easy.</li>\n<li>Similar to Angular, Nest also has a decent command line tool, available through Node Package Manager, nestjs/cli. The command line tool will let you scaffold the project, generate Nest architecture components, and display project information.</li>\n</ul>\n<h3>Disadvantages</h3>\n<ul>\n<li>The largest risk facing Nest users is the lack of documentation. The framework has great integrations with other frameworks but the documentation is minimal and doesn’t cover any issues that may arise.</li>\n<li>Nest does hold an edge in its use of TypeScript and relation to Angular, but it doesn’t have the backing power of a large enterprise behind it. </li>\n<li>Overall, Nest has a smaller community compared to other frameworks</li>\n</ul>\n<h3>Performance</h3>\n<p><img src=\"//images.ctfassets.net/hspc7zpa5cvq/1I29Vhrd0whIOGhQsGPMUT/8092e2e37a828c4cad9f70628854f378/nest.png\" alt=\"nest\"></p>\n<p>This is a basic Hello World app in Nest.js. It handles 928.18 requests per second. The average time spent per request is 10.774 ms. On this metric, Nest.js performed the best out of the three frameworks we compared. </p>\n<p><img src=\"//images.ctfassets.net/hspc7zpa5cvq/4bL41CK2YoIadG76nKqbgp/a4dd5d419adfee21dbfa09d8b7088c61/nest2.png\" alt=\"nest2\"></p>\n<p>In the report provided by lighthouse, Nest.js has a very high performance, but scored comparatively lower on other key factors:accessibility, best practices and SEO.</p>\n<h3>Community involvement</h3>\n<ul>\n<li><a href=\"https://github.com/nestjs/nest/graphs/contributors\">Number of contributors: 81</a>  </li>\n<li><a href=\"https://github.com/nestjs/nest/pulls\">Closed Pull Requests: 469</a> </li>\n</ul>\n<p>There is a group of developers providing handy packages on <a href=\"https://github.com/nestjs-community\">NestJS Community organization GitHub</a>. Some of their popular packages are: <a href=\"https://github.com/nestjs-community/nestjs-config\">nestjs-config</a>, a config module for NestJS using <code>dotenv</code>. <a href=\"https://github.com/nestjs-community/nest-access-control\">nest-access-control</a>, Role and Attribute-based access control for NestJS and <a href=\"https://github.com/nestjs-community/nestjs-flub\">nestjs-flub</a>, pretty error stack viewer.</p>\n<p>Even if Nest is not the most popular framework, is the one that has the better performance and has many advantages. You should give it a try! </p>\n<p>The community has a <a href=\"https://spectrum.chat/nestjs?tab=posts\">spectrum chat</a> and <a href=\"https://twitter.com/nestframework?lang=en\">Twitter</a></p>"}}},{"slug":"understanding-streams-in-node-js","title":"Understanding Streams in Node.js","createdAt":"May 30, 2020","author":{"name":"Liz Parody"},"image":{"file":{"url":"//images.ctfassets.net/xmu5vdhtphau/iF3PJ65DN4RZh7hUSRU5X/055bb44f2ab60b4efcea179638f68efe/21-min.jpg","fileName":"21-min.jpg"}},"bodyContent":{"childMarkdownRemark":{"html":"<p>Streams in Node.js have a reputation for being hard to work with, and even harder to understand. </p>\n<p>In the words of Dominic Tarr: “Streams are Node’s best and most misunderstood idea.” Even Dan Abramov, creator of Redux and core team member of React.js is afraid of Node streams.</p>\n<center>![dan](//images.ctfassets.net/hspc7zpa5cvq/6uij4d7kgJxdOy4ESjvKS5/24dc5102e9a1f2be5944a69062d0690b/dan.png)</center>\n<p>This article will help you understand streams and how to work with them. So, don’t be afraid. We can figure this out!</p>\n<h2>What are streams?</h2>\n<p>Streams are one of the fundamental concepts that power Node.js applications. They are data-handling method and are used to read or write input into output sequentially.</p>\n<p>Streams are a way to handle reading/writing files, network communications, or any kind of end-to-end information exchange in an efficient way.</p>\n<p>What makes streams unique, is that instead of a program reading a file into memory <strong>all at once</strong> like in the traditional way, streams read chunks of data piece by piece, processing its content without keeping it all in memory.</p>\n<p>This makes streams really powerful when working with <strong>large amounts of data</strong>, for example, a file size can be larger than your free memory space, making it impossible to read the whole file into the memory in order to process it. That’s where streams come to the rescue!</p>\n<p>Using streams to process smaller chunks of data, makes it possible to read larger files.</p>\n<p>Let’s take a “streaming” services such as YouTube or Netflix for example: these services don’t make you download the video and audio feed all at once. Instead,  your browser receives the video as a continuous flow of chunks, allowing the recipients to start watching and/or listening almost immediately. </p>\n<p>However, streams are not only about working with media or big data. They also give us the power of ‘composability’ in our code. Designing with composability in mind means several components can be combined in a certain way to produce the same type of result. In Node.js it’s possible to compose powerful pieces of code by piping data to and from other smaller pieces of code, using streams.  </p>\n<h2>Why streams</h2>\n<p>Streams basically provide two major advantages compared to other data handling methods:</p>\n<ol>\n<li><strong>Memory efficiency:</strong> you don’t need to load large amounts of data in memory before you are able to process it</li>\n<li><strong>Time efficiency:</strong> it takes significantly less time to start processing data as soon as you have it, rather than having to wait with processing until the entire payload has been transmitted </li>\n</ol>\n<h2>There are 4 types of streams in Node.js:</h2>\n<ol>\n<li><strong>Writable:</strong> streams to which we can write data. For example, <code>fs.createWriteStream()</code> lets us write data to a file using streams.</li>\n<li><strong>Readable:</strong> streams from which data can be read. For example: <code>fs.createReadStream()</code> lets us read the contents of a file.</li>\n<li><strong>Duplex:</strong> streams that are both Readable and Writable. For example, <code>net.Socket</code></li>\n<li><strong>Transform:</strong>  streams that can modify or transform the data as it is written and read. For example, in the instance of file-compression, you can write compressed data and read decompressed data to and from a file.</li>\n</ol>\n<p>If you have already worked with Node.js, you may have come across streams. For example, in a Node.js based HTTP server, <code>request</code> is a readable stream and <code>response</code> is a writable stream. You might have used the <code>fs</code> module, which lets you work with both readable and writable file streams. Whenever you’re using Express you are using streams to interact with the client, also, streams are being used in every database connection driver that you can work with, because of TCP sockets, TLS stack and other connections are all based on Node.js streams.</p>\n<h1>A practical example</h1>\n<h2>How to create a readable stream</h2>\n<p>We first require the Readable stream, and we initialize it.</p>\n<pre><code class=\"language-javascript\">const Stream = require('stream')\nconst readableStream = new Stream.Readable()\n</code></pre>\n<p>Now that the stream is initialized, we can send data to it:</p>\n<pre><code class=\"language-javascript\">readableStream.push('ping!')\nreadableStream.push('pong!')\n</code></pre>\n<h2>async iterator</h2>\n<p><strong>It’s highly recommended to use async iterator when working with streams.</strong> According to <a href=\"https://twitter.com/rauschma\">Dr. Axel Rauschmayer</a>, Asynchronous iteration is a protocol for retrieving the contents of a data container asynchronously (meaning the current “task” may be paused before retrieving an item). Also, it’s important to mention that the stream async iterator implementation use the ‘readable’ event inside.</p>\n<p>You can use async iterator when reading from readable streams:</p>\n<pre><code>import * as fs from 'fs';\n\nasync function logChunks(readable) {\n  for await (const chunk of readable) {\n    console.log(chunk);\n  }\n}\n\nconst readable = fs.createReadStream(\n  'tmp/test.txt', {encoding: 'utf8'});\nlogChunks(readable);\n\n// Output:\n// 'This is a test!\\n'\n</code></pre>\n<p><strong>It’s also possible to collect the contents of a readable stream in a string:</strong> </p>\n<pre><code>import {Readable} from 'stream';\n\nasync function readableToString2(readable) {\n  let result = '';\n  for await (const chunk of readable) {\n    result += chunk;\n  }\n  return result;\n}\n\nconst readable = Readable.from('Good morning!', {encoding: 'utf8'});\nassert.equal(await readableToString2(readable), 'Good morning!');\n</code></pre>\n<p>Note that, in this case, we had to use an async function because we wanted to return a Promise.</p>\n<p>It’s important to keep in mind to not mix async functions with <code>EventEmitter</code> because  currently, there is no way to catch a rejection when it is emitted within an event handler, causing hard to track bugs and memory leaks. The best current practice is to always wrap the content of an async function in a try/catch block and handle errors, but this is error prone. <a href=\"https://github.com/nodejs/node/pull/27867\">This pull request</a> aims to solve this issue once it lands on Node core.</p>\n<p>To learn more about Node.js streams via async iteration, check out <a href=\"https://2ality.com/2019/11/nodejs-streams-async-iteration.html\">this great article</a>.</p>\n<h3>Readable.from(): Creating readable streams from iterables</h3>\n<p><code>stream.Readable.from(iterable, [options])</code> it’s a utility method for creating Readable Streams out of iterators, which holds the data contained in iterable. Iterable can be a synchronous iterable or an asynchronous iterable. The parameter options is optional and can, among other things, be used to specify a text encoding.</p>\n<pre><code>const { Readable } = require('stream');\n\nasync function * generate() {\n  yield 'hello';\n  yield 'streams';\n}\n\nconst readable = Readable.from(generate());\n\nreadable.on('data', (chunk) => {\n  console.log(chunk);\n});\n</code></pre>\n<h3>Two Reading Modes</h3>\n<p>According to <a href=\"https://nodejs.org/api/stream.html#stream_stream\">Streams API</a>, readable streams effectively operate in one of two modes: <em>flowing</em> and <em>paused</em>. A Readable stream can be in object mode or not, regardless of whether it is in flowing mode or paused mode.</p>\n<ul>\n<li>In <strong>flowing mode</strong>, data is read from the underlying system automatically and provided to an application as quickly as possible using events via the EventEmitter interface.</li>\n<li>In <strong>paused mode</strong>, the <code>stream.read()</code> method must be called explicitly to read chunks of data from the stream.</li>\n</ul>\n<p><strong>In a flowing mode</strong>, to read data from a stream, it’s possible to listen to data event and attach a callback. When a chunk of data is available, the readable stream emits a data event and your callback executes. Take a look at the following snippet:</p>\n<pre><code class=\"language-javascript\">var fs = require(\"fs\");\nvar data = '';\n\nvar readerStream = fs.createReadStream('file.txt'); //Create a readable stream\n\nreaderStream.setEncoding('UTF8'); // Set the encoding to be utf8. \n\n// Handle stream events --> data, end, and error\nreaderStream.on('data', function(chunk) {\n   data += chunk;\n});\n\nreaderStream.on('end',function() {\n   console.log(data);\n});\n\nreaderStream.on('error', function(err) {\n   console.log(err.stack);\n});\n\nconsole.log(\"Program Ended\");\n</code></pre>\n<p>The function call <code>fs.createReadStream()</code> gives you a readable stream. Initially, the stream is in a static state. As soon as you listen to data event and attach a callback it starts flowing. After that, chunks of data are read and passed to your callback. The stream implementor decides how often a data event is emitted. For example, an HTTP request may emit a data event once every few KBs of data are read. When you are reading data from a file you may decide you emit a data event once a line is read.</p>\n<p>When there is no more data to read (end is reached), the stream emits an end event. In the above snippet, we listen to this event to get notified when the end is reached.</p>\n<p>Also, if there is an error, the stream will emit and notify the error.</p>\n<p><strong>In paused mode</strong>, you just need to call read() on the stream instance repeatedly until every chunk of data has been read, like in the following example: </p>\n<pre><code class=\"language-javascript\">var fs = require('fs');\nvar readableStream = fs.createReadStream('file.txt');\nvar data = '';\nvar chunk;\n\nreadableStream.on('readable', function() {\n    while ((chunk=readableStream.read()) != null) {\n        data += chunk;\n    }\n});\n\nreadableStream.on('end', function() {\n    console.log(data)\n});\n</code></pre>\n<p>The read() function reads some data from the internal buffer and returns it. When there is nothing to read, it returns null. So, in the while loop, we check for null and terminate the loop. Note that the readable event is emitted when a chunk of data can be read from the stream.</p>\n<hr>\n<p>All <code>Readable</code> streams begin in <strong>paused mode</strong> but can be switched to <strong>flowing mode</strong> in one of the following ways:</p>\n<ul>\n<li>Adding a 'data' event handler.</li>\n<li>Calling the <code>stream.resume()</code> method.</li>\n<li>Calling the <code>stream.pipe()</code> method to send the data to a Writable.</li>\n</ul>\n<p>The <code>Readable</code> can switch back to paused mode using one of the following:</p>\n<ul>\n<li>If there are no pipe destinations, by calling the <code>stream.pause()</code> method.</li>\n<li>If there are pipe destinations, by removing all pipe destinations. Multiple pipe destinations may be removed by calling the <code>stream.unpipe()</code> method.</li>\n</ul>\n<p>The important concept to remember is that a <code>Readable</code> will not generate data until a mechanism for either consuming or ignoring that data is provided. If the consuming mechanism is disabled or taken away, the <code>Readable</code> will <em>attempt</em> to stop generating the data.\nAdding a <code>readable</code> event handler automatically make the stream to stop flowing, and the data to be consumed via <code>readable.read()</code>. If the 'readable' event handler is removed, then the stream will start flowing again if there is a 'data' event handler.</p>\n<h2>How to create a writable stream</h2>\n<p>To write data to a writable stream you need to call <code>write()</code> on the stream instance. Like in the following example:</p>\n<pre><code class=\"language-javascript\">var fs = require('fs');\nvar readableStream = fs.createReadStream('file1.txt');\nvar writableStream = fs.createWriteStream('file2.txt');\n\nreadableStream.setEncoding('utf8');\n\nreadableStream.on('data', function(chunk) {\n    writableStream.write(chunk);\n});\n</code></pre>\n<p>The above code is straightforward. It simply reads chunks of data from an input stream and writes to the destination using <code>write()</code>. This function returns a boolean value indicating if the operation was successful. If true, then the write was successful and you can keep writing more data. If false is returned, it means something went wrong and you can’t write anything at the moment. The writable stream will let you know when you can start writing more data by emitting a drain event.</p>\n<p>Calling the <code>writable.end()</code> method signals that no more data will be written to the Writable. If provided, the optional callback function is attached as a listener for the 'finish' event.</p>\n<pre><code class=\"language-javascript\">// Write 'hello, ' and then end with 'world!'.\nconst fs = require('fs');\nconst file = fs.createWriteStream('example.txt');\nfile.write('hello, ');\nfile.end('world!');\n// Writing more now is not allowed!\n</code></pre>\n<p><strong>Using a writable stream you can read data from a readable stream:</strong></p>\n<pre><code class=\"language-javascript\">const Stream = require('stream')\n\nconst readableStream = new Stream.Readable()\nconst writableStream = new Stream.Writable()\n\nwritableStream._write = (chunk, encoding, next) => {\n    console.log(chunk.toString())\n    next()\n}\n\nreadableStream.pipe(writableStream)\n\nreadableStream.push('ping!')\nreadableStream.push('pong!')\n\nwritableStream.end()\n</code></pre>\n<p><strong>You can also use async iterators to write to a writable stream, which is recommended</strong></p>\n<pre><code>import * as util from 'util';\nimport * as stream from 'stream';\nimport * as fs from 'fs';\nimport {once} from 'events';\n\nconst finished = util.promisify(stream.finished); // (A)\n\nasync function writeIterableToFile(iterable, filePath) {\n  const writable = fs.createWriteStream(filePath, {encoding: 'utf8'});\n  for await (const chunk of iterable) {\n    if (!writable.write(chunk)) { // (B)\n      // Handle backpressure\n      await once(writable, 'drain');\n    }\n  }\n  writable.end(); // (C)\n  // Wait until done. Throws if there are errors.\n  await finished(writable);\n}\n\nawait writeIterableToFile(\n  ['One', ' line of text.\\n'], 'tmp/log.txt');\nassert.equal(\n  fs.readFileSync('tmp/log.txt', {encoding: 'utf8'}),\n  'One line of text.\\n');\n</code></pre>\n<p>The default version of stream.finished() is callback-based but can be turned into a Promise-based version via util.promisify() (line A).</p>\n<p>In this example, it is used the following two patterns:</p>\n<p>Writing to a writable stream while handling backpressure (line B):</p>\n<pre><code>if (!writable.write(chunk)) {\n  await once(writable, 'drain');\n}\n</code></pre>\n<p>Closing a writable stream and waiting until writing is done (line C):</p>\n<pre><code>writable.end();\nawait finished(writable);\n</code></pre>\n<h2>pipeline()</h2>\n<p>Piping is a mechanism where we provide the output of one stream as the input to another stream. It is normally used to get data from one stream and to pass the output of that stream to another stream. There is no limit on piping operations. In other words, piping is used to process streamed data in multiple steps.</p>\n<p>In Node 10.x was introduced <code>stream.pipeline()</code>. This is a module method to pipe between streams forwarding errors and properly cleaning up and provide a callback when the pipeline is complete.</p>\n<p>Here is an example of using pipeline:</p>\n<pre><code class=\"language-javascript\">const { pipeline } = require('stream');\nconst fs = require('fs');\nconst zlib = require('zlib');\n\n// Use the pipeline API to easily pipe a series of streams\n// together and get notified when the pipeline is fully done.\n// A pipeline to gzip a potentially huge video file efficiently:\n\npipeline(\n  fs.createReadStream('The.Matrix.1080p.mkv'),\n  zlib.createGzip(),\n  fs.createWriteStream('The.Matrix.1080p.mkv.gz'),\n  (err) => {\n    if (err) {\n      console.error('Pipeline failed', err);\n    } else {\n      console.log('Pipeline succeeded');\n    }\n  }\n);\n</code></pre>\n<p><code>pipeline</code> should be used instead of <code>pipe</code>, as pipe is unsafe.</p>\n<h2>The Stream Module</h2>\n<p>The <a href=\"https://nodejs.org/api/stream.html\">Node.js stream module</a> provides the foundation upon which all streaming APIs are build.</p>\n<p>The Stream module is a native module that shipped by default in Node.js. The Stream is an instance of the EventEmitter class which handles events asynchronously in Node. Because of this, streams are inherently event-based.</p>\n<p>To access the stream module:</p>\n<pre><code class=\"language-javascript\">const stream = require('stream');\n</code></pre>\n<p>The <code>stream</code> module is useful for creating new types of stream instances. It is usually not necessary to use the <code>stream</code> module to consume streams.</p>\n<h2>Streams-powered Node APIs</h2>\n<p>Due to their advantages, many Node.js core modules provide native stream handling capabilities, most notably:</p>\n<ul>\n<li><code>net.Socket</code> is the main node api that is stream are based on, which underlies most of the following APIs</li>\n<li><code>process.stdin</code> returns a stream connected to stdin</li>\n<li><code>process.stdout</code> returns a stream connected to stdout</li>\n<li><code>process.stderr</code> returns a stream connected to stderr</li>\n<li><code>fs.createReadStream()</code> creates a readable stream to a file</li>\n<li><code>fs.createWriteStream()</code> creates a writable stream to a file</li>\n<li><code>net.connect()</code> initiates a stream-based connection</li>\n<li><code>http.request()</code> returns an instance of the http.ClientRequest class, which is a writable stream</li>\n<li><code>zlib.createGzip()</code> compress data using gzip (a compression algorithm) into a stream</li>\n<li><code>zlib.createGunzip()</code> decompress a gzip stream.</li>\n<li><code>zlib.createDeflate()</code> compress data using deflate (a compression algorithm) into a stream</li>\n<li><code>zlib.createInflate()</code> decompress a deflate stream</li>\n</ul>\n<h2>Streams Cheat Sheet:</h2>\n<p><img src=\"//images.ctfassets.net/hspc7zpa5cvq/3s8p9qQe6zDEfhwLyq5fQR/7ce28dd384a590009aaaa16886bb83eb/cheat1.png\" alt=\"cheat1\"> <img src=\"//images.ctfassets.net/hspc7zpa5cvq/1vZrS7rb7U7DRb5TtT8hs8/bb6285794d4141c3a572770651fcc753/cheat2.png\" alt=\"cheat2\">\n<img src=\"//images.ctfassets.net/hspc7zpa5cvq/2rPAh1mmsLg02i0hLBG2DG/9829c1fb9cf396d952f1d155ce799f13/cheat3.png\" alt=\"cheat3\">\n<img src=\"//images.ctfassets.net/hspc7zpa5cvq/3HncUkiyjekdWjN8MwQbfi/29b3ad1806e8ce161a889c76667e780f/cheat3.png\" alt=\"cheat3\"> </p>\n<center>![Webp.net-resizeimage](//images.ctfassets.net/hspc7zpa5cvq/24pAlF9SE7EYkg4Xb2CtlW/8ae386aaf08e513372a09100bb8cd48a/Webp.net-resizeimage.png)</center>\n<center>See more: [Node.js streams cheatsheet](https://devhints.io/nodejs-stream)</center>\n<p>Here are some important events related to writable streams:</p>\n<ul>\n<li><code>error</code> – Emitted to indicate that an error has occurred while writing/piping.</li>\n<li><code>pipeline</code> – When a readable stream is piped into a writable stream, this event is emitted by the writable stream.</li>\n<li><code>unpipe</code> – Emitted when you call unpipe on the readable stream and stop it from piping into the destination stream.</li>\n</ul>\n<h2>Conclusion</h2>\n<p>This was all about the basics of streams. Streams, pipes, and chaining are the core and most powerful features in Node.js. Streams can indeed help you write neat and performant code to perform I/O.</p>\n<p>Also, there is a <a href=\"https://github.com/nodejs/TSC/blob/master/Strategic-Initiatives.md#current-initiatives\">Node.js strategic initiative</a> worth looking to, called <a href=\"https://github.com/Fishrock123/bob\">BOB</a>, aiming to improve Node.js streaming data interfaces, both within Node.js core internally, and hopefully also as future public APIs.</p>\n<h4>References</h4>\n<p>Special thanks to <a href=\"https://twitter.com/matteocollina\">Matteo Colina</a> and <a href=\"https://twitter.com/Fishrock123\">Jeremiah Senkpiel</a> for your feedback!</p>\n<ul>\n<li><a href=\"https://nodejs.org/api/stream.html\">Stream API</a></li>\n<li><a href=\"https://www.freecodecamp.org/news/node-js-streams-everything-you-need-to-know-c9141306be93/\">Node.js Streams: Everything you need to know</a></li>\n<li><a href=\"https://flaviocopes.com/nodejs-streams/\">Node.js Streams</a></li>\n<li><a href=\"https://www.sitepoint.com/basics-node-js-streams/\">The Basics of Node.js Streams</a></li>\n<li><a href=\"https://devhints.io/nodejs-stream\">Node.js streams cheatsheet</a></li>\n<li><a href=\"https://www.tutorialspoint.com/nodejs/nodejs_streams.htm\">Node.js - Streams</a></li>\n<li><a href=\"https://2ality.com/2019/11/nodejs-streams-async-iteration.html\">Easier Node.js streams via async iteration</a></li>\n<li><a href=\"https://changelog.com/jsparty/103\">You’re probably using streams</a></li>\n</ul>"}}},{"slug":"installing-node-js-tutorial-using-nvm-on-mac-os-x-and-ubuntu","title":"Installing Node.js Tutorial: Using nvm","createdAt":"May 16, 2020","author":{"name":"NodeSource"},"image":{"file":{"url":"//images.ctfassets.net/xmu5vdhtphau/1p4eEtLFdGcVSekU5ZnCTi/7544a13de1bae997de913ce0609374eb/15-min.png","fileName":"15-min.png"}},"bodyContent":{"childMarkdownRemark":{"html":"<p>This article was first published in <a href=\"https://nodesource.com/blog/installing-node-js-tutorial-using-nvm-on-mac-os-x-and-ubuntu/\">NodeSource blog</a> on January 2017.</p>\n<p>As with any programming language, platform, or tool, the first step to using it is getting it installed. Many of them typically come with a speedy way to upgrade when a new version is available. </p>\n<p>By default, there's not a way to upgrade the version of Node.js you've got from within Node.js itself. That said, there's a fantastic tool for the community called <a href=\"https://github.com/creationix/nvm\">nvm</a> that allows you to manage the versions of Node.js that you've got installed locally. </p>\n<p>One awesome aspect of <code>nvm</code> is that it <em>manages</em> the versions of Node.js, it doesn't just upgrade them. This means you can have the latest version of Node.js, the latest versions of all the LTS release lines, and any number of other versions you want to use or test as well.</p>\n<p>In this quick tutorial, we'll take a look at how to install nvm, and then how to start using it as your version manager for Node.js. Once we've completed the tutorial, you'll be ready to take the next step with Node.js.</p>\n<p>This guide covers installing nvm on macOS and Linux - note that all versions of Node.js may not support <em>every</em> version of macOS or Linux.  </p>\n<h2>Step 0: The Quick Guide (TL;DR) to Get Node.js Installed using nvm</h2>\n<p>Here's the abbreviated guide, highlighting the major steps:</p>\n<ul>\n<li>\n<p>Download the nvm install script via cURL: </p>\n<ul>\n<li><code>curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash</code></li>\n</ul>\n</li>\n<li>Ensure that nvm was installed correctly with <code>nvm --version</code>, which should return the version of nvm installed.</li>\n<li>\n<p>Install the version of Node.js you want</p>\n<ul>\n<li>Install the latest version with <code>nvm install node</code></li>\n<li>Use the latest version with <code>nvm use node</code></li>\n<li>Install the latest LTS version with <code>nvm install --lts</code></li>\n<li>Use the latest LTS verison with <code>nvm use --lts</code></li>\n</ul>\n</li>\n</ul>\n<h2>Step 1 (Optional): Ensure your system has the appropriate C++ compiler</h2>\n<p>In some cases, like when installing Node.js releases from their source or installing versions of Node.js <em>before</em> <code>0.8.6</code> (when the project started shipping binaries), you'll need to ensure that your system has the appropriate C++ build tools.</p>\n<p>For LTS and modern releases, you <strong>will not need this step</strong>. That said, it's a <em>nice to have</em> to ensure that the majority of requirements are met in any scenario.</p>\n<p>On <strong>macOS</strong>, you've got two options for a C++ compiler: the full XCode application or the stand-alone Command Line Tools portion of Xcode. </p>\n<p>To get these on macOS, you can follow these steps:</p>\n<ul>\n<li>Open your terminal of choice</li>\n<li>\n<p>Run <code>xcode-select --install</code> as a command</p>\n<ul>\n<li>A popup will appear</li>\n<li>Select <code>Install</code></li>\n</ul>\n</li>\n<li>Allow the download to run to completion</li>\n<li>If the installation went uninterrupted, you should have the necessary tools to use nvm! </li>\n</ul>\n<p>On <strong>Linux</strong>, the C++ compiler will vary from distribution to distribution. For example, on Debian and Ubuntu, you'll need to install <code>build-tools</code> and <code>libssl-dev</code>, but this may be different on your given Linux distribution.</p>\n<p>To get <code>build-tools</code> and <code>libssl-dev</code> on Debuan and Ubuntu distributions, you can run these commands:</p>\n<pre><code class=\"language-plain\">sudo apt-get install build-essential # Install the build-essential package - let this run to completion\n\nsudo apt-get install libssl-dev # Install the libssl-dev package - also let this one run to completion\n</code></pre>\n<h2>Step 2: Download nvm with the install script</h2>\n<p>Once you've got the right C++ compiler for your system, now it's time to run the nvm install script. Here are the single-step install scripts for both macOS and Linux. You've got the option of cURL or Wget but both achieve the same result. </p>\n<p><em>Note:</em> If your Linux system doesn't have either cURL or Wget, you can run <code>sudo apt-get install curl</code> and use the cURL method.</p>\n<h3>Running the Install Script with cURL:</h3>\n<p>To install nvm with the cURL method, run the following command in your terminal:</p>\n<pre><code class=\"language-plain\">curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash\n</code></pre>\n<h3>Using the Install Script with Wget:</h3>\n<p>To install nvm with the Wget method, run the following command in your terminal:</p>\n<pre><code class=\"language-plain\">wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash\n</code></pre>\n<h2>Step 3: Verify that nvm was Properly installed</h2>\n<p>After running the install script from Step 2, nvm should have successfully installed. To ensure that nvm is up and running on your machine, you can test it with the following command:</p>\n<pre><code class=\"language-plain\">nvm --version\n</code></pre>\n<p>This command will return something like (though not necessarily exactly) the following: </p>\n<pre><code class=\"language-plain\">nvm --version # The command we ran - it checks the currently installed version of nvm\n0.33.0 # The current version of nvm - yours may differ!\n</code></pre>\n<h3>Missing the <code>nvm</code> command after running the install script?</h3>\n<p>If you're using macOS, you may be missing a <code>.bash_profile</code> file - to troubleshoot this, you can run <code>touch ~/.bash_profile</code> in your command line and re-run the installer script.</p>\n<p>If the problem persists after that, you can open the existing <code>.bash_profile</code> file (using your favorite text editor) and add the following line to it:</p>\n<pre><code class=\"language-plain\">source ~/.bashrc\n</code></pre>\n<p>If you're still having issues, you can take a peek at <a href=\"https://github.com/creationix/nvm/issues/576\">this issue</a> to find a discussion of the problem and a collection of possible resolutions.</p>\n<h2>Step 3: Using nvm to manage Node.js</h2>\n<p>Congratulations! You've now got <code>nvm</code> - a tool to <em>easily</em> allow you to manage and swap out the versions of Node.js you've got installed locally. Now, let's get you started with doing just that.</p>\n<h3>Install the latest Node.js version</h3>\n<p>To install the latest available version of Node.js, you can use the following command: </p>\n<pre><code class=\"language-plain\">nvm install node\n</code></pre>\n<p>Next, to <em>use</em> that version of Node.js in any new shell, you can simply run the <code>use</code> command:</p>\n<pre><code class=\"language-plain\">nvm use node\n</code></pre>\n<h3>Install the latest Node.js LTS version</h3>\n<p>To install the latest available <em>LTS</em> version of Node.js, you can run the following command: </p>\n<pre><code class=\"language-plain\">nvm install --lts\n</code></pre>\n<p>And to use that latatestTS version of Node.js in any new shell, you can simply run the <code>use</code> command:</p>\n<pre><code class=\"language-plain\">nvm use --lts\n</code></pre>\n<h2>Step 6: Go build applications, APIs, tools, and more with Node.js!</h2>\n<p>Now you've got a fantastic version manager for Node.js. It's time to start building!</p>\n<div class=\"blog-cta nsolid\">\n\tGet unparalleled visibility into application performance and system health.\n  <a class=\"button more large\" href=\"https://accounts.nodesource.com/sign-up-blogref/?utm_campaign=blogref&utm_source=blog&utm_content=blog-install-nvm\">Get started with N|Solid today</a>\n</div>\n<p>We've got some resources to get you kickstarted! Both the breadth and depth of the Node.js and the JavaScript ecosystems are quite large - in addition to the developer tools like <a href=\"https://nodesource.com/products/nsolid\">NodeSource N|Solid</a> and <a href=\"https://certified.nodesource.com/\">Certified Modules</a>, we've got a ton of tutorials, guides, and articles to help you get kick started with Node.js.</p>\n<p>If you're interested in keeping your code clean, maintainable, and collaborative, take a peek at our post on <a href=\"https://nodesource.com/blog/streamline-javascript-development-with-eslint\">using ESLint for linting your JavaScript applications</a>. Are you interested in building web applications with Node.js? One of the most challenging aspects of web apps is security - you can learn <a href=\"https://nodesource.com/blog/nine-security-tips-to-keep-express-from-getting-pwned\">security best practices for Express</a> to lock down your web apps, to prevent breaches and attacks. Or, maybe you want to deploy your Node.js apps with Docker? Then you should <em>definitely</em> read our article on <a href=\"https://nodesource.com/blog/8-protips-to-start-killing-it-when-dockerizing-node-js\">dockerizing your Node.js applications</a>.</p>\n<p>That said, if you want to keep in touch with the Node.js ecosystem, you should follow <a href=\"http://twitter.com/nodesource\">@NodeSource</a> on Twitter! We'll keep you updated with important news from the core Node.js project, fresh and useful Node.js tutorials, and more.</p>"}}}],"videos":[{"slug":"need-to-node-volume-66","title":"Need to Node – Volume 66","image":{"file":{"url":"//images.ctfassets.net/xmu5vdhtphau/47M1ZCRvNDb4uYnCpN89QG/ec93803c06da2a34b1bc40514c107497/3-min.png","fileName":"3-min.png"}},"bodyContent":{"childMarkdownRemark":{"html":"<p>In this volume of Need to Node, you can find the latest news on Node.js’s version 14 Release, Diagnostics in Node.js and The Cost of JavaScript Frameworks</p>\n<p>Need to Node is a weekly bulletin designed to keep you up-to-date with the latest news on the Node.js project, events and articles. You are always welcome to collaborate and participate. Please let us know if we missed a piece of content you think should be included!</p>\n<h2>What’s New in the Node.js Project</h2>\n<ul>\n<li>\n<p><a href=\"https://medium.com/@nodejs/node-js-version-14-available-now-8170d384567e\">Node.js version 14 Released</a> — Woo-hoo it’s finally here! Node.js v.14 now becomes the current release line with it becoming a LTS (Long Term Support) release in October. It’s recommended to keep using Node.js version 12 for now. Some of the most exciting features include: </p>\n<ul>\n<li>Diagnostic Report goes Stable</li>\n<li>V8 upgraded to V8 8.1</li>\n<li>Experimental Async Local Storage API</li>\n<li>Improvements to Streams.</li>\n<li>Experimental WebAssembly System Interface (WASI) to support future WebAssembly use cases.</li>\n<li>Removal of Experimental Modules Warning (but it still is experimental).</li>\n</ul>\n</li>\n</ul>\n<h2>Awesome Articles, Links, and Resources</h2>\n<ul>\n<li><a href=\"https://nodesource.com/blog/diagnostics-in-NodeJS-2\">Diagnostics in Node.js Part 2</a>, useful techniques for diagnostics in Node.js - by <a href=\"https://twitter.com/lizparody23\">lizparody</a></li>\n<li><a href=\"https://vercel.com/blog/zeit-is-now-vercel\">ZEIT is now Vercel</a> This new identity aligns with their new focus — to provide the ultimate workflow for developing, previewing, and shipping Jamstack sites. They also raised $21M in Series A funding.</li>\n<li><a href=\"https://www.npmtrends.com/\">npm trends</a> a useful tool to compare package downloads counts over time. By <a href=\"https://twitter.com/johnmpotter\">John Potter</a></li>\n<li><a href=\"https://github.com/jesseduffield/lazynpm\">Lazy npm</a> A simple terminal UI for npm commands. By <a href=\"https://github.com/jesseduffield\">Jesse Duffield</a></li>\n<li>\n<p><a href=\"https://timkadlec.com/remembers/2020-04-21-the-cost-of-javascript-frameworks/\">The Cost of JavaScript Frameworks</a>. With JavaScript you end up paying a performance tax no less than four times:</p>\n<ul>\n<li>The cost of downloading the file on the network</li>\n<li>The cost of parsing and compiling the uncompressed file once downloaded</li>\n<li>The cost of executing the JavaScript</li>\n<li>The memory cost\nRead this blog post to find out more! By <a href=\"https://timkadlec.com/\">Tim Kadlec</a></li>\n</ul>\n</li>\n<li><a href=\"https://blog.bitsrc.io/recommended-github-integrations-for-2020-35042c71cb69\">Recommended GitHub Integrations for 2020</a> IDE integrations, GitHub bots, issue trackers and much more — to help you make the most out of GitHub. By <a href=\"https://twitter.com/deleteman123\">Fernando Doglio</a></li>\n<li><a href=\"https://levelup.gitconnected.com/8-basic-coding-conventions-every-developer-needs-to-practice-5846252146ec\">8 Basic Coding Conventions Every Developer Needs To Practice</a>. Including: spaces vs tabs, naming conventions and practice proper directory structure. By <a href=\"https://levelup.gitconnected.com/@annadayadev\">Ann Adaya</a></li>\n</ul>\n<h2>One Last Thing...</h2>\n<p>If you find any Node.js or JavaScript related content over the next week (or beyond!), never hesitate to reach out to us on Twitter at <a href=\"https://twitter.com/nodesource\">@NodeSource</a> to share and get it included in Need to Node - our DMs are open if you don’t want to share publicly!</p>"}}},{"slug":"new-features-nodejs-version-14","title":"New and Exciting Features to Land in Node.js Version 14","image":{"file":{"url":"//images.ctfassets.net/xmu5vdhtphau/4HIwVhFjrKrBmds10NlfeW/4193d762cccd04afeef8b9baba8ce772/1-min.png","fileName":"1-min.png"}},"bodyContent":{"childMarkdownRemark":{"html":"<p>Node.js 14 has just been released. It comes with full of new features and enhancements. More importantly, it will be promoted to Long-Term Support in October, so now it's the moment to start testing our applications and try the new features to ensure a smooth transition.</p>\n<p>In this webinar we will be showing the most relevant of these new features.</p>"}}},{"slug":"need-to-node-volume-64","title":"Need to Node – Volume 64","image":{"file":{"url":"//images.ctfassets.net/xmu5vdhtphau/4pkqP0mjoj4FuZpgYCTicI/06b9039051055aefb5796f9ee82a5e66/2-min.png","fileName":"2-min.png"}},"bodyContent":{"childMarkdownRemark":{"html":"<p>In this volume of Need to Node, you can find the latest news on the Node.js v13.11.0 (Current) Release, npm is joining GitHub and Three Things You Didn't Know You Could Do with npm Scripts.</p>\n<p>Need to Node is a weekly bulletin designed to keep you up to date with the latest news on the Node.js project, events and awesome articles. You are always welcome to collaborate and participate. Please let us know if we missed a piece of content you think should be included!</p>\n<h2>What’s New in the Node.js Project</h2>\n<ul>\n<li>🚨 <a href=\"https://github.blog/2020-03-16-npm-is-joining-github/?utm_campaign=1584377606&#x26;utm_medium=social&#x26;utm_source=twitter&#x26;utm_content=1584377606\">npm is joining GitHub</a> 🙀.  On March 16th, Nat Friedman CEO of GitHub, announced that an agreement to acquire npm has been signed. The central  focus of the acquisition will be to (1) invest in the registry infrastructure and platform, (2) improve the core experience and (3) engage with the community. Check out the blog post!</li>\n<li><a href=\"https://github.com/nodejs/node/pull/32181\">The (Ongoing) Node 14.0 Pull Request</a> Check out what’s going on with the road to Node 14! The cut-off date for new features making it into this release is coming up later this month with the eventual release being due in late April (and running V8 8.1).</li>\n<li><a href=\"https://github.com/nodejs/node/releases/tag/v13.11.0\">Node 13.11.0 (Current) Released</a>. A minor release that includes updates in <code>async_hooks</code>, <code>cli</code> and <code>fs</code>.</li>\n</ul>\n<h2>Awesome Articles, Links, and Resources</h2>\n<ul>\n<li><a href=\"http://thecodebarbarian.com/building-a-github-app-with-node-js.html\">Building a GitHub App With Node.js</a>. In this article you can learn how to build a GitHub app that enforces pinning exact dependencies in your package.json: no <code>^</code>, <code>>=</code>, or <code>*</code> required. Exciting! By <a href=\"https://twitter.com/code_barbarian\">Valeri Karpov</a> </li>\n<li><a href=\"https://www.twilio.com/blog/npm-scripts\">Three Things You Didn't Know You Could Do with npm Scripts</a>. This article covers the basics of using npm scripts along with three features that are not widely used, but  might find useful in your workflow - by <a href=\"https://twitter.com/DKundel\">Domink Kundel</a></li>\n<li><a href=\"http://www.wirfs-brock.com/allen/posts/866\">JavaScript: The First 20 Years</a> <a href=\"https://twitter.com/awbjs\">Allen Wirfs-Brock</a> and <a href=\"https://twitter.com/BrendanEich\">Brendan Eich</a> (the creator of JavaScript) have written a paper for the forthcoming History of Programming Languages Conference about how JavaScript was built and has grown. It goes deep on the tech and syntax development side of things.</li>\n<li><a href=\"https://yunchi.dev/posts/demystifying-async/\">Demystifying Async Programming in Javascript</a> Asynchronous programming in Javascript has undergone several evolutions, from callbacks to promises to generators, and soon to async/await. Check out this article to find out more! By <a href=\"https://github.com/mightyguava\">Yunchi Luo</a></li>\n<li><a href=\"https://typeofnan.dev/what-is-a-higher-order-function/\">What is a Higher-Order Function?</a> A higher-order function is a function that either takes a function as an argument or returns a function. Don’t miss this blog post to learn more along with some useful examples! By <a href=\"https://twitter.com/nas5w\">Nick Scialli</a></li>\n<li><a href=\"https://ckeditor.com/blog/Aborting-a-signal-how-to-cancel-an-asynchronous-task-in-JavaScript/\">Aborting a signal: How to cancel an asynchronous task in JavaScript</a> Performing asynchronous tasks can be hard, fortunately, JavaScript offers a very handy piece of functionality for aborting an asynchronous activity. In this article, you can learn how to use it to create your own abortable function. By <a href=\"https://twitter.com/Comandeer2\">Tomasz Jakut</a></li>\n</ul>\n<h2>One Last Thing...</h2>\n<p>If you find any Node.js or JavaScript related content over the next week (or beyond!), never hesitate to reach out to us on Twitter at <a href=\"https://twitter.com/nodesource\">@NodeSource</a> to share and get it included in Need to Node - our DMs are open if you don’t want to share publicly!</p>"}}}]},"allContentfulPost":{"edges":[{"node":{"slug":"meet-anna-henningsen-core-contributor-and-engineer","title":"Meet Anna Henningsen - Core Contributor & Engineer","headLine":"What keeps me motivated to work on Node.js is the community and the technological challenge. Having the opportunity to improve the developer experience for thousands, maybe millions of people, that’s a very unique thing, and I think it is worth a lot.","avatar":{"file":{"url":"//images.ctfassets.net/xmu5vdhtphau/2ewVjWlpCbAxvJ9XuGFot8/bad24efcea89a8ef5b61053883b17e73/anna.jpg","fileName":"anna.jpg"}}}},{"node":{"slug":"meet-adrian-estrada-vp-of-engineering-nodesource","title":"Meet Adrian Estrada - VP of Engineering @ NodeSource","headLine":"It was definitely about creating opportunities for others.  I know I can do something to help  and provide opportunities to people so I do what I can to transform the city. ","avatar":{"file":{"url":"//images.ctfassets.net/xmu5vdhtphau/5oi3ODySdvXsDHM6Xv33aa/ae6683cc99c4bc09774ba85add0b9d34/adri.jpeg","fileName":"adri.jpeg"}}}},{"node":{"slug":"meet-trevor-norris-core-contributor-and-engineer-nodesource","title":"Meet Trevor Norris - Core Contributor & Engineer @ NodeSource","headLine":"One of the best things about working in open source is that you get to work on what you find most interesting. It is easy to stay involved in open source because you can pick and choose what you want to work on. But it's not always easy.","avatar":{"file":{"url":"//images.ctfassets.net/xmu5vdhtphau/61I48ZBFi43Wp3FIaGk6Js/f198079b401c1a004f6b4a40bd0c0f8c/tnorris.jpeg","fileName":"tnorris.jpeg"}}}}]}},"pageContext":{}}}