Streams & Buffer
As something so important in Node, it should be a high priority thing to learn about and you cannot talk about streams without mentioning buffer, ArrayBuffer, pipe, back pressure, etc. It is also important to master all the stream types, writable, readable, transform, and duplex.
Streams allow for time and memory-efficient data transferring which is definitely something you want to take advantage of taking into consideration the single-threaded server-side nature of NodeJS.
Events & Event Emitters
When you start working with streams, you can’t help to notice that you listen to stream events and this is because it uses event emitters(event module) to send the various types of events like “error”, “end” and “data”.
Pretty much everything in Node emits Events and you should learn to incorporate events in your application by creating your own events and utilize the event emitter. NodeJs is built around an idiomatic asynchronous event-driven architecture where emitters run the show.
On the server-side, you will have to deal with files by reading them, writing to them, or collecting information about them. That makes the fs (File System) module an important module to master and know your way around it.
You will need to know how to read files and directories, perform CRUD operations, and collect details about them like permission, name, and size. When interacting with the File System you will automatically interact with streams and events as well, which further highlights the need to learn those concepts in depth.
You are on the Server! That is enough reason to try to learn the HTTP, HTTP2, and HTTPS modules. Many modules have been built on this module like ExpressJs but learning your way around the Node HTTP modules will make you appreciate these modules much more.
HTTP is not just about learning the module itself, it is also about learning how the server-side of things work. How things get to the server (requests), connection (agent), in what format (header, body), what information they contain, how to respond (response) to them, what details you can include are all important concepts to take a deep dive into.
Module & Architecture
You cant talk about Node without talking about the Modular architecture and Modules. The idea that every file is a module (implements the module pattern) with its own scope and you can choose what to expose or not pretty much defines NodeJs applications.
NodeJs Modules work by wrapping the code in your file in a function that injects global things like require, exports, __dirname, and more into your file. Understanding that, will explain a lot about how communication is done, what are the restrictions, emphasizes the need for Events, and facilitates the building of workers and threads.
The global object is essential, and you can’t avoid it. It contains things available on every module like require, exports, and __dirname. It also contains timer functions like setTimeout and setInterval as well as your favorite, the console.
On the browser, you create a global variable(with var) which will be available everywhere (global scope). With NodeJs things are different, the top level is the module itself so, any “global” variable you create is local to the module and you choose what the module exports to the rest of the application which by importing you know exactly what each module needs and where they all come from.
Cluster & Process
The process object is available globally(through the global object) and it provides details on the current running process by NodeJs. It is commonly used to get arguments the NodeJs was executed with, read, and write to the console, etc. For example, the console object wraps around the process for those abilities but you will need to take a deeper dive into process when you work with Cluster.
Clusters improve your application by giving it the ability to handle a bigger load and understanding your way around processes allows you to create more powerful applications Cluster processes.
Child Process & Worker Threads
Child process is a different module that allows you to run subprocess. Cluster uses the child process fork method to spawn different processes that allow back and forward communication. Child process is often used to interact with the shell and to run code from a different language like python. It is my favorite way to run shell scripts and commands.
Worker threads share memory and are perfect for complex data calculation, monitoring and process data for your main application, perform intensive and long database operations, etc. The equivalent on the browser would be the Web Worker.
Path, URL, Util & More
You can’t forget the built-in modules meant to aid you with everything else. The path lets you handle relative paths in your file system. URL helps with anything URL related and the utility module is just a box of magic.
The utility module comes with type checks functions, text encoder, and decoder, util to check deep equality, promisify callbacks, inspect and format various things, etc. I rarely feel the need to install something with these awesome modules and you need to be familiar with them.
Becoming a Pro NodeJs goes beyond these 10 things as NodeJs is so much more. I do believe these are the 10 things to start with if you are heading in that direction though. They allow you to start creating useful things enough to fall in love with NodeJs and further seek more about it.
It goes without saying that practice and experience play a big part and you should try to expose yourself to as many things as possible. Becoming a Pro is a journey and not a destination so take your time to digest things.
YouTube Channel: Before Semicolon