Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Node.js Cookbook

You're reading from   Node.js Cookbook Practical recipes for building server-side web applications with Node.js 22

Arrow left icon
Product type Paperback
Published in Nov 2024
Publisher Packt
ISBN-13 9781804619810
Length 456 pages
Edition 5th Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Bethany Griggs Bethany Griggs
Author Profile Icon Bethany Griggs
Bethany Griggs
Manuel Spigolon Manuel Spigolon
Author Profile Icon Manuel Spigolon
Manuel Spigolon
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. Chapter 1: Introducing Node.js 22 2. Chapter 2: Interacting with the File System FREE CHAPTER 3. Chapter 3: Working with Streams 4. Chapter 4: Using Web Protocols 5. Chapter 5: Developing Node.js Modules 6. Chapter 6: Working with Fastify – The Web Framework 7. Chapter 7: Persisting to Databases 8. Chapter 8: Testing with Node.js 9. Chapter 9: Dealing with Security 10. Chapter 10: Optimizing Performance 11. Chapter 11: Deploying Node.js Microservices 12. Chapter 12: Debugging Node.js 13. Index 14. Other Books You May Enjoy

Enabling Node.js core debug logs

When debugging some problems in your applications, it can be useful to have insight into the internals of Node.js and how it handles the execution of your program. Node.js provides debug logs that we can enable to help us understand what is happening internally in Node.js.

These core debug logs can be enabled via an environment variable named NODE_DEBUG. In the recipe, we’re going to set the NODE_DEBUG environment variable to allow us to log internal Node.js behaviors.

Getting ready

We’ll need to create an application on which we can enable Node.js core debug logs:

  1. We’ll create a simple Express.js-based server with one route:
    $ mkdir core-debug-logs
    $ cd core-debug-logs
    $ npm init --yes
    $ npm install express
    $ touch server.js
  2. Add the following to server.js:
    const express = require('express');
    const app = express();
    app.get('/', (req, res) => {
      res.send('Hello World!&apos...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image