node

Why –legacy-peer-deps is Better than –force in npm

Why –legacy-peer-deps is Better than –force in npm

When managing dependencies in a Node.js project, you might encounter scenarios where installing packages results in conflicts or warnings due to peer dependency issues. Two common ways developers address this are using the --legacy-peer-deps flag or the --force flag with npm. While both methods can resolve dependency issues temporarily, --legacy-peer-deps is generally the safer and more reliable choice. Let’s dive into the details of these options, their use cases, and why you should prefer --legacy-peer-deps over --force. Understanding Peer Dependencies Peer dependencies in npm are a way for a package to specify that it works alongside a specific version of…
Read More
Exploring CPU-Bound and I/O-Bound Tasks: Inside the libuv Library in Node.js

Exploring CPU-Bound and I/O-Bound Tasks: Inside the libuv Library in Node.js

In software development and system design, understanding CPU-bound and I/O-bound tasks is crucial for optimizing applications and selecting the right technology stack. These concepts primarily relate to application performance bottlenecks and can help developers design efficient multithreading and asynchronous programs. System Model A computer system can be abstracted as: Input (Keyboard) -> Processing (CPU) -> Output (Monitor) Enter fullscreen mode Exit fullscreen mode Input and output fall under the category of I/O, while computation is handled by the CPU. A single-machine program, consisting of multiple methods or functions executed in sequence or parallel, can be abstracted as: Input Parameters ->…
Read More
Custom logging in Next.js

Custom logging in Next.js

Next.js does not have a way to use a custom logger for server-side uncaught exceptions and rejections. While you can use a library like next-logger to help, you will be limited to using Pino only. This doesn't help if you want to use another logging library or even ship the logs to a cloud provider like DataDog. Instead, you can use the LogLayer logging library to capture these exceptions and ship them off to your favorite logging library like Pino and DataDog at the same time. Check the LogLayer site for supported loggers and cloud providers. Install This guide assumes…
Read More
Compilation of Libraries Supporting CLI Application Development for Node.js

Compilation of Libraries Supporting CLI Application Development for Node.js

Hello everyone. I wonder if anyone here has been using command-line applications (CLI)? If so, why did you choose it over a graphical user interface (GUI)? If I remember correctly, I have written a few articles about the process of creating some applications for myself. Honestly, for me, there are many cases where CLI proves to be much more useful. Recalling my early days of switching from Windows to Linux, specifically Ubuntu. I have cursed countless times about this damn operating system. The interface is ugly, hard to use, and everything requires typing commands; how can anyone remember all those…
Read More
Node.js v23.6.0: Built-in TypeScript Support is Finally Here

Node.js v23.6.0: Built-in TypeScript Support is Finally Here

Node.js v23.6.0 was recently released, and it comes with a significant update: the unflagging of --experimental-strip-types. This means Node.js can now run TypeScript files natively without any additional configuration. Why TypeScript Matters TypeScript enhances JavaScript by introducing optional static typing and advanced features such as interfaces, generics, and type inference. Over the years, it has become the de facto standard for large-scale JavaScript applications. With this integration into Node.js, TypeScript becomes even more accessible to backend developers. Running TypeScript in Node.js To execute a TypeScript file in Node.js, simply run: node index.ts Enter fullscreen mode Exit fullscreen mode In addition…
Read More
SSO Gone Wrong: Insights from a Real Breach

SSO Gone Wrong: Insights from a Real Breach

In one of my past projects, we experienced a critical security breach when a white-hat security researcher reported a vulnerability that allowed unauthorized access to one of our root system admin accounts. This superuser account was designed to facilitate support operations, granting access to other accounts for internal use only. While the situation could have been catastrophic, we were fortunate for two key reasons: The Researcher’s Intentions Were Ethical: The security researcher acted with goodwill and a bounty incentive. They demonstrated that they could log in without exploiting the access to harm or compromise client data. Notably, the researcher did…
Read More
Introduction to the Node.js Module System

Introduction to the Node.js Module System

Modules are at the heart of every Node.js application. Here’s how they work: 1️⃣ Built-in Modules:Node.js comes with modules like: fs for file handlinghttp for creating serverspath for file paths 2️⃣ Custom Modules:Create a module by exporting code: // myModule.jsmodule.exports = function greet() {console.log("Hello from my module!");}; Use it in another file: const greet = require('./myModule');greet(); 3️⃣ Third-Party Modules: Install libraries via npm: npm install express Import it using require(). The module system ensures clean, maintainable, and scalable applications. What’s your go-to module in Node.js? Our next one we will be diving into details on it....... Source link lol
Read More
Node.js Meets PostgreSQL and MongoDB in Docker: Docker Diaries

Node.js Meets PostgreSQL and MongoDB in Docker: Docker Diaries

Recently, I had to create a NodeJS application where I had to connect to 2 different database in PostgreSQL and MongoDB. For application scaling, I had to use Docker and Kubernetes. Here's how I connected all these inside docker. In order to run this whole thing using docker-compose, visit this repo: https://github.com/fahadfahim13/node-pg-mongo-docker.git Project Setup Run the following commands with your preferred project name: mkdir node-postgres-mongo cd node-postgres-mongo npm init -y Enter fullscreen mode Exit fullscreen mode The install these dependencies: npm install express pg mongoose dotenv Enter fullscreen mode Exit fullscreen mode Inside this project, create an index.js file and…
Read More
Node.js Architecture: How It Works

Node.js Architecture: How It Works

The secret behind Node.js lies in its unique architecture: 1️⃣ Single-Threaded Event Loop: Unlike traditional multi-threaded models, Node.js uses a single thread for all operations, relying on asynchronous programming to handle multiple requests. 2️⃣ Non-Blocking I/O: All I/O operations (e.g., file reads, database queries) are non-blocking, ensuring high performance under heavy loads. 3️⃣ Event-Driven: Events and callbacks keep the system responsive, ideal for building real-time applications. 4️⃣ V8 Engine: Node.js uses Google’s V8 engine for executing JavaScript, offering speed and efficiency. Thanks to this architecture, Node.js is perfect for chat applications, APIs, and streaming platforms. What’s your favorite Node.js use…
Read More
No widgets found. Go to Widget page and add the widget in Offcanvas Sidebar Widget Area.