Registry / http-networking / debug-http

debug-http

JSON →
library1.1.0jsnpmunverified

debug-http is a minimalist Node.js utility designed to intercept and log all outgoing HTTP and HTTPS requests made within an application. It achieves this by patching Node.js's built-in `http` and `https` modules to provide visibility into request details like URL, method, and headers. The package is currently at version 1.1.0 and has not seen updates in nearly a decade, indicating it is no longer actively maintained. Its primary function is a simple, global request handler that outputs request information to the console by default, though it allows for a custom handler function. Due to its age, it exclusively supports CommonJS module loading and does not officially support modern JavaScript features like ESM or TypeScript. Alternatives like `debug` or `request-debug` offer more robust and actively maintained debugging capabilities, especially for specific HTTP client libraries or more granular control over debug output.

npm install debug-http
INSTALL
IMPORT
SIG · DEBUG-HTTP
D
debug-http
http-networkingjavascriptv1.1.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

debugHttp
import debugHttp from 'debug-http'
const debugHttp = require('debug-http').debugHttp;
The package is primarily CommonJS, but this is the hypothetical ESM import. The default export is the function itself. The CommonJS `require` call directly returns the function, so `require('debug-http').debugHttp` is incorrect.
debugHttp
const debugHttp = require('debug-http');
This is the correct and intended CommonJS import for the package, which exports the main function directly.

This example demonstrates how to enable global HTTP/HTTPS request debugging and then make a simple HTTP and HTTPS GET request, logging their status. It also shows a commented-out custom handler.

const debugHttp = require('debug-http'); const http = require('http'); const https = require('https'); // Enable HTTP/HTTPS request debugging globally debugHttp(); console.log('Making an HTTP GET request to google.com...'); http.get('http://google.com', (res) => { console.log(`HTTP GET to google.com status: ${res.statusCode}`); res.resume(); // Consume response data to free up memory }).on('error', (e) => { console.error(`HTTP GET error: ${e.message}`); }); console.log('Making an HTTPS GET request to github.com...'); https.get('https://github.com', (res) => { console.log(`HTTPS GET to github.com status: ${res.statusCode}`); res.resume(); // Consume response data }).on('error', (e) => { console.error(`HTTPS GET error: ${e.message}`); }); // Example with a custom handler function // debugHttp((type, data) => { // console.log(`[${type.toUpperCase()}] Custom Handler:`, data.url || data.path); // });
Debug
Known issues
breakingThis package globally patches Node.js's built-in `http` and `https` modules. This can lead to unexpected behavior or conflicts if other modules in your application also attempt to patch these core modules or rely on their unpatched behavior. Use with caution in larger applications.
fix
Thoroughly test your application when using global patching modules. Consider alternatives like `request-debug` for specific HTTP client libraries, or the `debug` package for application-level logging that doesn't modify core modules.
affects: >=1.0.0
gotchaThe `debug-http` package is unmaintained, with its last update over 10 years ago. It may not be compatible with newer Node.js versions, modern HTTP features, or security best practices, and will not receive updates for bugs or vulnerabilities.
fix
Evaluate modern alternatives like `debug` for general-purpose debugging or specific debugging middleware/tools for your HTTP client (e.g., `axios-debug-log` for Axios). If using it, pin the exact version and consider forking if critical updates are needed.
affects: >=1.0.0
gotchaThe package only supports CommonJS module loading (`require`). Attempting to `import debugHttp from 'debug-http'` in an ESM context will result in an error or undefined behavior due to the lack of an explicit ESM export.
fix
Ensure your project is configured for CommonJS, or use dynamic `import()` for ESM projects: `const debugHttp = await import('debug-http'); debugHttp.default();` (though this package exports directly, so `debugHttp()` after dynamic import is likely correct).
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: debugHttp is not a function
This error often occurs when attempting to destructure the `require` result, or if using `require('debug-http').debugHttp` in CommonJS. The package directly exports the function, not an object with a named export.
fix
Correct the CommonJS import to `const debugHttp = require('debug-http');` and then call `debugHttp();`.
ERR_REQUIRE_ESM: require() of ES Module ... not supported
This package is a CommonJS module and cannot be directly `require()`d from an ES Module context without specific Node.js configuration or dynamic imports.
fix
If your project is ESM, either switch back to CommonJS, configure Node.js to handle CJS in ESM (e.g., `"type": "commonjs"` in `package.json`), or use a dynamic import: `const debugHttpModule = await import('debug-http'); debugHttpModule.default();` (though for `debug-http`, it's `debugHttpModule()`).
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
15 hits · last 30 days
node
12
OpenAI (training)
2
Resources
debug-http — npm install debug-http · libregistry