Node.js
Learn to become a modern Node.js developer by following the steps, skills, resources and guides listed in this pack.
1/ 113
Node.js Introduction
Node.js is an open source, cross-platform runtime environment and library that is used for running web applications outside the client’s browser.
It is used for server-side programming, and primarily deployed for non-blocking, event-driven servers, such as traditional web sites and back-end API services, but was originally designed with real-time, push-based architectures in mind. Every browser has its own version of a JS engine, and node.js is built on Google Chrome’s V8 JavaScript engine.
Visit the following resources to learn more:
Node.js Introduction
Node.js is an open source, cross-platform runtime environment and library that is used for running web applications outside the client’s browser.
It is used for server-side programming, and primarily deployed for non-blocking, event-driven servers, such as traditional web sites and back-end API services, but was originally designed with real-time, push-based architectures in mind. Every browser has its own version of a JS engine, and node.js is built on Google Chrome’s V8 JavaScript engine.
Visit the following resources to learn more:
1/113
What is Node.js
Node.js is an open-source and cross-platform JavaScript runtime environment. It is a popular tool for almost any kind of project! Node.js runs the V8 JavaScript engine, Google Chrome’s core, outside the browser. This allows Node.js to be very performant. A Node.js app runs in a single process, without creating a new thread for every request.
Node.js provides a set of asynchronous I/O primitives in its standard library that prevent JavaScript code from blocking and generally, libraries in Node.js are written using non-blocking paradigms, making blocking behavior the exception rather than the norm.
Visit the following resources to learn more:
2/113
Why Node.js
Node.js is a cross-platform runtime, perfect for a wide range of use cases. Its huge community makes it easy to get started. It uses the V8 engine to compile JavaScript and runs at lightning-fast speeds. Node.js applications are very scalable and maintainable. Cross-platform support allows the creation of all kinds of applications - desktop apps, software as a service, and even mobile applications. Node.js is perfect for data-intensive and real-time applications since it uses an event-driven, non-blocking I/O model, making it lightweight and efficient. With such a huge community, a vast collection of Node.js packages is available to simplify and boost development.
Visit the following resources to learn more:
3/113
History of Node.js
Node.js was written initially by Ryan Dahl in 2009, about thirteen years after the introduction of the first server-side JavaScript environment, Netscape’s LiveWire Pro Web. The initial release supported only Linux and macOS X. Its development and maintenance were led by Dahl and later sponsored by Joyent.
Visit the following resources to learn more:
4/113
Nodejs vs Browser
Both the browser and Node.js use JavaScript as their programming language. Building apps that run in the browser is entirely different than building a Node.js application. Even though it’s always JavaScript, some key differences make the experience radically different.
Visit the following resources to learn more:
5/113
Running Node.js Code
The usual way to run a Node.js program is to run the globally available
node
command (once you install Node.js) and pass the name of the file you want to execute.
Visit the following resources to learn more:
6/113
Node.js Modules
We split our code into different files to maintain, organize and reuse code whenever possible. A module system allows us to split and include code and import code written by other developers whenever required. In simple terms, a module is nothing but a JavaScript file. Node.js has many built-in modules that are part of the platform and comes with Node.js installation, for example, HTTP, fs, path, and more.
Visit the following resources to learn more:
7/113
CommonJS vs ESM
CommonJS and ES (EcmaScript) are module systems used in Node. CommonJS is the default module system. However, a new module system was recently added to NodeJS - ES modules. CommonJS modules use the require() statement for module imports and module.exports for module exports while it’s import and export for ES.
Visit the following resources to learn more:
8/113
ESM
ESM (ECMAScript Modules) is a standardized module system in JavaScript that allows for the organized, maintainable, and reusable structuring of code. It uses import and export statements for including and sharing functions, objects, or primitives between files. ESM supports static analysis, enabling better optimization and tooling, and is always in strict mode to reduce common JavaScript issues. Node.js fully supports ESM, which can be used with .mjs file extensions or configured in the package.json for .js files, making it easier to write modular and efficient JavaScript applications.
Visit the following resources to learn more:
9/113
Custom Modules
Modules are the collection of JavaScript codes in a separate logical file that can be used in external applications based on their related functionality. There are two ways to create modules in Node.js i.e. either via CommonJS or ESM.
Visit the following resources to learn more:
10/113
global keyword
In browsers, the top-level scope is the global scope, and its global object is called the
window
object. Within the browser, var something
will define a new global variable inside the window
object. In Node.js, this is different. The top-level scope is not the global scope; var something
inside a Node.js module will be local to that module.
Visit the following resources to learn more:
11/113
npm
npm is the standard package manager for Node.js.
It is two things: first and foremost, it is an online repository for the publishing of open-source Node.js projects; second, it is a command-line utility for interacting with said repository that aids in package installation, version management, and dependency management. A plethora of Node.js libraries and applications are published on npm, and many more are added every day
Visit the following resources to learn more:
12/113
Global Install vs Local Install
NodeJS and NPM allow two methods of installing dependencies/packages: Local and Global. This is mainly used when adding a package or dependency as part of a specific project you’re working on. The package would be installed (with its dependencies) in
node_modules
folder under your project. In addition, in package.json
file there will be a new line added for the installed dependency under the label dependencies
. At this point - you can start using the package in your NodeJS code by importing the package. Unlike the local install, you can install packages and dependencies globally. This would install it in a system path, and these packages would be available to any program which runs on this specific computer. This method is often used for installing command line tools (for example, even npm
program is a Globally installed npm package).
Visit the following resources to learn more:
13/113
Local Installation
Locally installed packages are available only to the project where the packages are installed, while the globally installed packages can be used any where without installing them into a project. Another use case of the global packages is when using CLI tools.
Visit the following resources to learn more:
14/113
Updating Packages
npm provides various features to help install and maintain the project’s dependencies. Dependencies get updates with new features and fixes, so upgrading to a newer version is recommended. We use
npm update
commands for this.
Visit the following resources to learn more:
15/113
Running Scripts
In Node.js, npm scripts are used for the purpose of initiating a server, starting the build of a project, and also for running the tests. We can define this scripts in the package.json file of the folder. Also, we can split the huge scripts into many smaller parts if it is needed.
Visit the following resources to learn more:
16/113
npm workspaces
Workspace is a generic term that refers to the set of npm CLI features that support managing multiple packages from your local file system from within a singular top-level root package.
Visit the following resources to learn more:
17/113
Creating Packages
npm packages allow you to bundle some specific functionality into a reusable package which can then be uploaded to some package registry such as npm or GitHub packages and then be installed and reused in projects using npm.
Visit the following resources to learn more:
18/113
Semantic Versioning
Semantic Versioning is a standard for versioning software that’s widely adopted in the npm ecosystem. It provides a clear and consistent way to communicate changes in a software package to users.
A semantic version number consists of three parts separated by dots:
MAJOR: Incremented when there are incompatible API changes.
MINOR: Incremented when new functionality is added in a backwards-compatible manner.
PATCH: Incremented when bug fixes are made without affecting the API.
1 is the major version.
2 is the minor version.
3 is the patch version.
Visit the following resources to learn more:
19/113
Error Handling
Error handling is a way to find bugs and solve them as quickly as humanly possible. The errors in Node.js can be either operation or programmer errors. Read the articles linked below to understand how to handle different types of errors in Node.js
Visit the following resources to learn more:
20/113
Javascript Errors
JavaScript Errors are used by JavaScript to inform developers about various issue in the script being executed. These issues can be syntax error where the developer/programmer has used the wrong syntax, it can be due to some wrong user input or some other problem.
JavaScript has six types of errors that may occur during the execution of the script:
EvalError
RangeError
ReferenceError
SyntaxError
TypeError
URIError
Visit the following resources to learn more:
21/113
System Errors
Node.js generates system errors when exceptions occur within its runtime environment. These usually occur when an application violates an operating system constraint.
For example, a system error will occur if an application attempts to read a file that does not exist.
Below are the system errors commonly encountered when writing a Node.js program
EACCES - Permission denied
EADDRINUSE - Address already in use
ECONNRESET - Connection reset by peer
EEXIST - File exists
EISDIR - Is a directory
EMFILE - Too many open files in system
ENOENT - No such file or directory
ENOTDIR - Not a directory
ENOTEMPTY - Directory not empty
ENOTFOUND - DNS lookup failed
EPERM - Operation not permitted
EPIPE - Broken Pipe
ETIMEDOUT - Operation timed out
Visit the following resources to learn more:
22/113
User Specified Errors
User specified errors can be created by extending the base Error object, a built-in error class. When creating errors in this manner, you should pass a message string that describes the error. This message can be accessed through the message property on the object. The Error object also contains a name and a stack property that indicate the name of the error and the point in the code at which it is created.
Visit the following resources to learn more:
23/113
Assertion Errors
An
AssertionError
in Node.js is an error that is thrown when the assert
module determines that a given expression is not truthy. The assert
module is a built-in Node.js module that provides a simple set of assertion tests that can be used to test the behavior of your code.
Visit the following resources to learn more:
24/113
Uncaught Exceptions
When a JavaScript error is not properly handled, an uncaughtException is emitted. These suggest the programmer has made an error, and they should be treated with the utmost priority.
The correct use of
uncaughtException
is to perform synchronous cleanup of allocated resources (e.g. file descriptors, handles, etc) before shutting down the process. It is not safe to resume normal operation after uncaughtException
because system becomes corrupted. The best way is to let the application crash, log the error and then restart the process automatically using nodemon or pm2.
Visit the following resources to learn more:
25/113
Async errors
Errors must always be handled. If you are using synchronous programming you could use a try catch. But this does not work if you work asynchronous! Async errors will only be handled inside the callback function!
Visit the following resources to learn more:
26/113
Stack Trace
The stack trace is used to trace the active stack frames at a particular instance during the execution of a program. The stack trace is useful while debugging code as it shows the exact point that has caused an error.
Visit the following resources to learn more:
27/113
Using Debugger
Node.js includes a command-line debugging utility. The Node.js debugger client is not a full-featured debugger, but simple stepping and inspection are possible. To use it, start Node.js with the inspect argument followed by the path to the script to debug.
Example -
$ node inspect myscript.js
Visit the following resources to learn more:
28/113
npx
npx is a very powerful command that’s been available in npm starting version 5.2, released in July 2017. If you don’t want to install npm, you can install npx as a standalone package. npx lets you run code built with Node.js and published through the npm registry, without needing to install the package itself. This is particularly useful for trying out new tools, running one-time commands, or using packages in shared environments where global installations are undesirable. npx takes care of downloading the package on-the-fly, running the desired command, and then cleaning up the temporary installation. This keeps your project’s dependencies lean and avoids version conflicts.
Visit the following resources to learn more:
29/113
Nodejs async programming
Asynchronous code means that things can happen independently of the main program flow, async functions in JavaScript are processed in the background without blocking other requests. It ensures non-blocking code execution. Asynchronous code executes without having any dependency and no order. This improves the system efficiency and throughput. Making web apps requires knowledge of asynchronous concepts since we will be dealing with actions that require some time to get processed.
Visit the following resources to learn more:
30/113
Promises
A promise is commonly defined as a proxy for a value that will eventually become available.
Asynchronous functions use promise behind the scenes, so understanding how promises work is fundamental to understanding how “async” and “await” works.
Once a promise has been called, it will start in a pending state. This means that the calling function continues executing, while the promise is pending until it resolves, giving the calling function whatever data was being requested.
Creating a Promise:
The Promise API exposes a Promise constructor, which you initialize using new Promise().
Using resolve() and reject(), we can communicate back to the caller what the resulting Promise state was, and what to do with it.
Visit the following resources to learn more:
31/113
Async/Await
Async/Await is a special syntax to work with promises in a more comfortable fashion. It’s easy to understand and use. Adding the keyword async before a function ensures that the function returns a promise and the keyword await makes JavaScript wait until that promise settles and returns the result.
Visit the following resources to learn more:
32/113
Callbacks
Node.js, being an asynchronous platform, doesn’t wait around for things like file I/O to finish - Node.js uses callbacks. A callback is a function called at the completion of a given task; this prevents any blocking, and allows other code to be run in the meantime.
Visit the following resources to learn more:
33/113
setTimeout
The setTimeout runs a function after the specified period expires. Times are declared in milliseconds.
Visit the following resources to learn more:
34/113
setInterval
The
setInterval()
method helps us to repeatedly execute a function after a fixed delay. It returns a unique interval ID which can later be used by the clearInterval()
method, which stops further repeated execution of the function.
setInterval()
is similar to setTimeout, with a difference. Instead of running the callback function once, it will run it forever, at the specific time interval you specify (in milliseconds):
Visit the following resources to learn more:
35/113
setImmediate
The
setImmediate
function delays the execution of a function to be called after the current event loops finish all their execution. It’s very similar to calling setTimeout
with 0 ms delay.
Visit the following resources to learn more:
36/113
process.nextTick()
Every time the event loop takes a full trip, we call it a tick. When we pass a function to
process.nextTick()
, we instruct the engine to invoke this function at the end of the current operation before the next event loop tick starts.
Visit the following resources to learn more:
37/113
Event Emitter
In Node.js, an event can be described simply as a string with a corresponding callback. An event can be “emitted” (or, in other words, the corresponding callback be called) multiple times or you can choose to only listen for the first time it is emitted.
Visit the following resources to learn more:
38/113
Event Loop
The Event Loop is one of the most critical aspects of Node.js. Why is this so important? Because it explains how Node.js can be asynchronous and have non-blocking I/O, it explains the “killer feature” of Node.js, which made it this successful.
Visit the following resources to learn more:
39/113
Working with Files
You can programmatically manipulate files in Node.js with the built-in
fs
module. The name is short for “file system,” and the module contains all the functions you need to read, write, and delete files on the local machine.
Visit the following resources to learn more:
40/113
process.cwd()
The
process.cwd()
method returns the current working directory of the Node.js process.
Visit the following resources to learn more:
41/113
path module
The
path
module provides utilities for working with file and directory paths. It’s built-in to Node.js core and can simply be used by requiring it.
Visit the following resources to learn more:
42/113
fs module
File System or
fs
module is a built in module in Node that enables interacting with the file system using JavaScript. All file system operations have synchronous, callback, and promise-based forms, and are accessible using both CommonJS syntax and ES6 Modules.
Visit the following resources to learn more:
43/113
__dirname
The
__dirname
in a node script returns the path of the folder where the current JavaScript file resides. __filename
and __dirname
are used to get the filename and directory name of the currently executing file.
Visit the following resources to learn more:
44/113
__filename
The
__filename
in Node.js returns the filename of the executed code. It gives the absolute path of the code file. The following approach covers implementing __filename
in the Node.js project.
Visit the following resources to learn more:
45/113
Glob
The glob pattern is most commonly used to specify filenames, called wildcard characters, and strings, called wildcard matching.
Visit the following resources to learn more:
46/113
Globby
User-friendly glob matching
Based on fast-glob but adds a bunch of useful features.
Visit the following resources to learn more:
47/113
fs-extra
fs-extra adds file system methods that aren’t included in the native fs module and adds promise support to the fs methods. It also uses graceful-fs to prevent EMFILE errors. It should be a drop in replacement for fs.
Visit the following resources to learn more:
48/113
Chokidar
Chokidar is a fast open-source file watcher for node. js. You give it a bunch of files, it watches them for changes and notifies you every time an old file is edited; or a new file is created.
Visit the following resources to learn more:
49/113
Command Line Applications
Command Line Applications are applications that can be run from the command line. They are also called CLI (Command Line Interface) applications. Users can interact with clients entirely by terminal commands. They are very useful for automation and building tools.
Visit the following resources to learn more:
50/113
dotenv
dotenv is a zero-dependency module that loads environment variables from a
.env
file into process.env
. Storing configuration in the environment separate from code is based on The Twelve-Factor App methodology.
Visit the following resources to learn more:
51/113
process.env
In Node. js, process. env is a global variable that is injected during runtime. It is a view of the state of the system environment variables. When we set an environment variable, it is loaded into process.env during runtime and can later be accessed.
Visit the following resources to learn more:
52/113
Exiting and exit codes
Exiting
is a way of terminating a Node.js process by using node.js process module.
Visit the following resources to learn more:
53/113
Process stdin
The
process.stdin
is a standard Readable stream which listens for user input and is accessible via the process module. It uses on()
function to listen for input events.
Visit the following resources to learn more:
54/113
Prompts
Prompts is a higher level and user friendly interface built on top of Node.js’s inbuilt
Readline
module. It supports different type of prompts such as text, password, autocomplete, date, etc. It is an interactive module and comes with inbuilt validation support.
Visit the following resources to learn more:
55/113
Inquirer
Inquirer.js is a collection of common interactive command line interfaces for taking inputs from user.
It is promise based and supports chaining series of prompt questions together, receiving text input, checkboxes, lists of choices and much more.
You can use it to empower your terminal applications that need user input or to build your own CLI.
Visit the following resources to learn more:
56/113
Process stdout
The
process.stdout
property is an inbuilt application programming interface of the process module which is used to send data out of our program. A Writable Stream to stdout. It implements a write()
method.
console.log()
prints to the process.stdout.write()
with formatted output or new line.
Visit the following resources to learn more:
57/113
Chalk
Chalk is a clean and focused library used to do string styling in your terminal applications. With it, you can print different styled messages to your console such as changing font colors, font boldness, font opacity, and the background of any message printed on your console.
Visit the following resources to learn more:
58/113
Figlet
This package aims to fully implement the FIGfont spec in JavaScript, which represents the graphical arrangement of characters representing larger characters. It works in the browser and with Node.js.
Visit the following resources to learn more:
59/113
Cli progress
CLI-Progress is a package that provides a custom progress bar for CLI applications.
Visit the following resources to learn more:
60/113
process.argv
process.argv
is an array of parameters that are sent when you run a Node.js file or Node.js process.
Visit the following resources to learn more:
61/113
Commander.js
Commander is a light-weight, expressive, and powerful command-line framework for node.js. with Commander.js you can create your own command-line interface (CLI).
Visit the following resources to learn more:
62/113
APIs
API is the acronym for Application Programming Interface, which is a software intermediary that allows two applications to talk to each other.
Visit the following resources to learn more:
63/113
Express.js
Express is a node js web application framework that provides broad features for building web and mobile applications. It is used to build a single page, multi-page, and hybrid web application.
Visit the following resources to learn more:
64/113
Fastify
Fastify is a web framework highly focused on providing the best developer experience with the least overhead and a powerful plugin architecture, inspired by Hapi and Express.
Visit the following resources to learn more:
65/113
NestJS
NestJS is a progressive Node.js framework for creating efficient and scalable server-side applications.
Visit the following resources to learn more:
66/113
Hono
Hono is a lightweight, simple, and fast web framework for Cloudflare Workers, Deno, Bun, and other applications. It is a modern web application that is both fast and flexible. It offers inbuilt support for TypeScript, and easy development in a local environment. Using Hono, It is easy to create publishable web applications with Deno, Bun, and Cloudflare Workers.
Visit the following resources to learn more:
67/113
Making API calls with HTTP
You can make API calls using the
http
module in Node.js as well. Here are the two methods that you can use:
http.get()
- Make http GET requests.
http.request()
- Similar to http.get()
but enables sending other types of http requests (GET requests inclusive).
Visit the following resources to learn more:
68/113
Axios
Axios is a promise-based HTTP Client for node.js and the browser. Used for making requests to web servers. On the server-side it uses the native node.js http module, while on the client (browser) it uses XMLHttpRequests.
Visit the following resources to learn more:
69/113
Ky
Ky is a tiny and elegant HTTP client based on the browser Fetch API. Ky targets modern browsers and Deno.For older browsers, you will need to transpile and use a fetch polyfill.For Node.js, check out Got.. 1 KB (minified & gzipped), one file, and no dependencies.
Visit the following resources to learn more:
70/113
fetch
The
fetch()
method in JavaScript is used to request to the server and load the information on the webpages. The request can be of any APIs that return the data of the format JSON or XML. This method returns a promise.
Visit the following resources to learn more:
71/113
Got
Got is a lighter, human-friendly, and powerful HTTP request library explicitly designed to work with Node.js. It supports pagination, RFC compliant caching, makes an API request again if it fails, supports cookies out of the box, etc.
Visit the following resources to learn more:
72/113
JSON Web Token
JWT, or JSON-Web-Token, is an open standard for sharing security information between two parties — a client and a server. Each JWT contains encoded JSON objects, including a set of claims. JWTs are signed using a cryptographic algorithm to ensure that the claims cannot be altered after the token is issued.
Visit the following resources to learn more:
73/113
Passport js
Passport.js is authentication middleware for Node.js. It makes implementing authentication in express apps really easy and fast. It is extremely flexible and modular. It uses “strategies” to support authentication using a username and password, Facebook, Twitter, and a lot of other sites.
Visit the following resources to learn more:
74/113
Keep App Running
In Node.js, you need to restart the process to make changes take effect. This adds an extra step to your workflow. You can eliminate this extra step by using
nodemon
to restart the process automatically.
Since Node.js 18.11.0, you can run Node with the --watch
flag to reload your app everytime a file is changed. So you don’t need to use nodemon
anymore.
Node.js 18.11.0 Changelog.
75/113
—watch
The
--watch
flag in Node.js is a powerful feature introduced in Node.js version 19 that enables automatic reloading of your Node.js application whenever changes are detected in the specified files.
You run your Node.js script with the --watch
flag: $ node --watch your_script.js
Node.js starts watching the specified file (or directory) for changes.
Whenever a change is detected, Node.js automatically restarts the script
Visit the following resources to learn more:
76/113
Nodemon
In Node.js, you need to restart the process to make changes take effect. This adds an extra step to your workflow. You can eliminate this extra step by using nodemon or PM2 to restart the process automatically.
nodemon
is a command-line interface (CLI) utility developed by @rem that wraps your Node app, watches the file system, and automatically restarts the process.
Visit the following resources to learn more:
77/113
Template Engines
Template engine helps us to create an HTML template with minimal code. Also, it can inject data into HTML template at client side and produce the final HTML.
Some examples of template engines in Node.js are:
Nunjucks
Jade
Vash
EJS
Handlebars
HAML
78/113
EJS
EJS is a template language or engine that allows you to generate HTML markup with pure JavaScript. And this is what makes it perfect for Nodejs applications.
In simple words, the EJS template engine helps to easily embed JavaScript into your HTML template.
Visit the following resources to learn more:
79/113
Pug
Pug is a JavaScript template engine. It is a high-performance template engine heavily influenced by Haml and implemented with JavaScript for Node.js and browsers. Pug was formerly called Jade.
Pug is a high-performance template engine heavily influenced by Haml and implemented with JavaScript for Node.js and browsers
Visit the following resources to learn more:
80/113
Marko
Marko is a fast and lightweight HTML-based templating engine that compiles templates to CommonJS modules and supports streaming, async rendering, and custom tags. It is HTML re-imagined as a language for building dynamic and reactive user interfaces.
Visit the following resources to learn more:
81/113
What is Database
A database is an organized collection of structured information, or data, typically stored electronically in a computer system. A database is usually controlled by a database management system (DBMS).
Visit the following resources to learn more:
82/113
Mongoose
Mongoose is an Object Data Modeling (ODM) library for MongoDB and Node.js. Mongoose provides a straight-forward, schema-based solution to model your application data. It includes built-in type casting, validation, query building, business logic hooks and more, out of the box.
Visit the following resources to learn more:
83/113
Prisma
Prisma provides an open source next-generation ORM in the TypeScript ecosystem. It offers a dedicated API for relation filters. It provides an abstraction layer that makes you more productive compared to writing SQL. Prisma currently supports
PostgreSQL
, MySQL
, SQL Server
, SQLite
, MongoDB
and CockroachDB
.
Visit the following resources to learn more:
84/113
Native Drivers
Another way to connect to different databases in Node.js is to use the official native drivers provided by the database. For example, here is the list of drivers by MongoDB
85/113
Knex
Knex.js is a “batteries included” SQL query builder for PostgreSQL, CockroachDB, MSSQL, MySQL, MariaDB, SQLite3, Better-SQLite3, Oracle, and Amazon Redshift designed to be flexible, portable, and fun to use.
Visit the following resources to learn more:
86/113
Drizzle
Drizzle lets you build your project the way you want, without interfering with your project or structure. Using Drizzle you can define and manage database schemas in TypeScript, access your data in a SQL-like or relational way, and take advantage of opt-in tools to make your developer experience amazing.
Visit the following resources to learn more:
87/113
TypeORM
TypeORM is an ORM that can run in NodeJS, Browser, Cordova, PhoneGap, Ionic, React Native, NativeScript, Expo, and Electron platforms and can be used with TypeScript and JavaScript (ES5, ES6, ES7, ES8). Its goal is to always support the latest JavaScript features and provide additional features that help you to develop any kind of application that uses databases - from small applications with a few tables to large scale enterprise applications with multiple databases.
TypeORM supports both Active Record and Data Mapper patterns, unlike all other JavaScript ORMs currently in existence, which means you can write high quality, loosely coupled, scalable, maintainable applications the most productive way.
Visit the following resources to learn more:
88/113
Sequelize
Sequelize is an easy-to-use and promise-based Node.js ORM tool for Postgres, MySQL, MariaDB, SQLite, DB2, Microsoft SQL Server, and Snowflake. It features solid transaction support, relations, eager and lazy loading, read replication and more.
An ORM is known as Object Relational Mapper. This is a tool or a level of abstraction which maps(converts) data in a relational database into programmatic objects that can be manipulated by a programmer using a programming language(usually an OOP language). ORMs solely exist to map the details between two data sources which due to a mismatch cannot coexist together.
Visit the following resources to learn more:
89/113
Prisma
Prisma is an ORM that helps app developers build faster and make fewer errors. Combined with its Data Platform developers gain reliability and visibility when working with databases.
Visit the following resources to learn more:
90/113
Native drivers
NativeDriver is an implementation of the WebDriver API which drives the UI of a native application rather than a web application. It extends the WebDriver API in a few key places, and re-interprets the existing API for native applications.
91/113
Testing
Software testing is the process of verifying that what we create is doing exactly what we expect it to do. The tests are created to prevent bugs and improve code quality.
The two most common testing approaches are unit testing and end-to-end testing. In the first, we examine small snippets of code, in the second, we test an entire user flow.
Visit the following resources to learn more:
92/113
Vitest
Vitest is a Vite-native unit testing framework that’s Jest-compatible. Vitest is a powerful testing library built on top of Vite that is growing in popularity. You can use Vitest for a range of testing needs, such as unit, integration, end-to-end (E2E), snapshot, and performance testing of functions and components. ESM, TypeScript, JSX. Out-of-box ESM, TypeScript and JSX support powered by esbuild. Vitest is free and open source.
Visit the following resources to learn more:
93/113
node:test
node:test
is a built-in module in Node.js that provides a simple, asynchronous test runner. It’s designed to make writing tests as straightforward as writing any other code.
Simplicity: Easy to use and understand.
Asynchronous Support: Handles asynchronous code gracefully.
Subtests: Allows for organizing tests into hierarchical structures.
Hooks: Provides beforeEach and afterEach hooks for setup and teardown.
Visit the following resources to learn more:
94/113
Jest
Jest is a delightful JavaScript Testing Framework with a focus on simplicity. It works with projects using: Babel, TypeScript, Node, React, Angular, Vue and more!
Visit the following resources to learn more:
95/113
Playwright
Playwright is an open-source automation library developed by Microsoft for testing and automating web applications. 1 It offers a unified API to control Chromium, Firefox, and WebKit browsers, making it a versatile choice for cross-browser testing.
Playwright provides a high-level API to interact with web pages. You can write scripts to simulate user actions, such as clicking buttons, filling forms, and navigating through different pages. Playwright handles the underlying browser interactions, making it easy to write and maintain tests.
Visit the following resources to learn more:
96/113
Cypress
Cypress is a new front end testing tool built for the modern web. It enables you to write faster, easier and more reliable tests.
Visit the following resources to learn more:
97/113
Node.js Logging
Logging is an essential part of understanding the complete application life cycle of the
Node.js
application. We can much more easily and quickly fix errors by looking at logs throughout the development process, from creating to debugging to designing new features. Error, warn, info, and debug are the four basic logging levels in Node.js
. Logging involves persistently collecting information about an application’s runtime behaviour.
Visit the following resources to learn more:
98/113
Winston
winston is designed to be a simple and universal logging library with support for multiple transports. A transport is essentially a storage device for your logs. Each winston logger can have multiple transports configured at different levels. For example, one may want error logs to be stored in a persistent remote location (like a database), but all logs output to the console or a local file.
Visit the following resources to learn more:
99/113
Morgan
Morgan is a NodeJS and express.js middleware to log the HTTP request and error, simplifying the debugging process. It provides flexibility in defining the format of log messages and helps override the output destination for your logs.
Visit the following resources to learn more:
100/113
Keep your app running in Production
PM2 lets you run your nodejs scripts forever. In the event that your application crashes, PM2 will also restart it for you.
Visit the following resources to learn more:
101/113
Pm2
PM2 is a production process manager for Node.js applications with a built-in load balancer. It allows you to keep applications alive forever, to reload them without downtime and to facilitate common system admin tasks.
Visit the following resources to learn more:
102/113
Nodejs Threads
Node.js is a single-threaded language and gives us ways to work parallelly to our main process.
Taking note of nowadays multicore system single threading is very memory efficient.
Visit the following resources to learn more:
103/113
Child Process
The child_process module gives the node the ability to run the child process, established through IPC (inter-process communication) by accessing operating system commands.
The three main methods inside this module are :
child_process.spawn()
child_process.fork()
child_process.exec()
Visit the following resources to learn more:
104/113
Cluster
The Cluster module allows you to easily create child processes that each runs simultaneously on their own single thread, to handle workloads among their application threads.
Visit the following resources to learn more:
105/113
Worker Threads
Worker thread is a continuous parallel thread that runs and accepts messages until it is explicitly closed or terminated.
With worker threads, we can achieve a much efficient application without creating a deadlock situation. Workers, unlike children’s processes, can exchange memory.
Visit the following resources to learn more:
106/113
Nodejs streams
Streams are a type of data handling methods and are used to read, write or transform chunks of data piece by piece without keeping it in memory all at once. There are four types of streams in Node.js.
Readable: streams from which data can be read.
Writable: streams to which we can write data.
Duplex: streams that are both Readable and Writable.
Transform: streams that can modify or transform the data as it is written and read.
Multiple streams can be chained together using
pipe()
method.
Visit the following resources to learn more:
107/113
More Debugging
Debugging is a concept to identify and remove errors from software applications. Here, we will learn about the technique to debug a Node.js application.
Using
console.log
to debug the code generally dives into an infinite loop of “stopping the app and adding a console.log, and start the app again” operations. Besides slowing down the development of the app, it also makes the writing dirty and creates unnecessary code. Finally, trying to log out variables alongside with the noise of other potential logging operations, may make the process of debugging difficult when attempting to find the values you are debugging.
Visit the following resources to learn more:
108/113
Memory Leaks
Memory leaks are caused when your Node.js app’s CPU and memory usage increases over time for no apparent reason. In simple terms, a Node.js memory leak is an orphan block of memory on the Heap that is no longer used by your app because it has not been released by the garbage collector. It’s a useless block of memory. These blocks can grow over time and lead to your app crashing because it runs out of memory.
Visit the following resources to learn more:
109/113
Node Inspect
Node.js provides a built-in DevTools-based debugger to allow debugging Node.js applications.
Visit the following resources to learn more:
110/113
Using APM
As much fun as it is to intercept your container requests with inspect and step through your code, you won’t have this option in production. This is why it makes a lot of sense to try and debug your application locally in the same way as you would in production.
In production, one of your tools would be to login to your remote server to view the console logs, just as you would on local. But this can be a tedious approach. Luckily, there are tools out there that perform what is called log aggregation, such as Stackify.
These tools send your logs from your running application into a single location. They often come with high-powered search and query utilities so that you can easily parse your logs and visualize them.
Visit the following resources to learn more:
111/113
Garbage Collection
Memory management in JavaScript is performed automatically and invisibly to us. We create primitives, objects, functions… All that takes memory. The main concept of memory management in JavaScript is reachability.
Visit the following resources to learn more:
112/113
Nodejs core modules
These are the core modules that come with
Node.js
out of the box. This module provides tools or APIs for performing out certain standard Node.js
operations. like interacting with the file system, url parsing, or logging information to the console.
Learn more from the following resources:
113/113
Начать обучение
Создать ежедневную практику
СоздатьWitSlice © 2024