Registry / observability / obug
library2.1.1jsnpmunverified

obug is a lightweight JavaScript debugging utility, forked from the popular `debug` package, specifically engineered for modern JavaScript environments. It offers comprehensive TypeScript support and native ES Module (ESM) compatibility, making it suitable for contemporary Node.js applications and browser environments (ES2015+). The current stable version is 2.1.1, with recent updates focusing on performance enhancements and customizable features. Unlike its predecessor `debug`, obug prioritizes a minimal footprint (7.7 kB package size, 1.4 KB minified + gzipped for browsers) and zero external dependencies. Key differentiators include full TypeScript type definitions, native ESM support from the ground up, and an API optimized for modern runtimes. Version 2 introduced a significant rewrite, refactoring API imports and usage for improved modularity, customization, and further reduced package size compared to v1, which aimed for `debug` compatibility but dropped older runtime support.

npm install obug
INSTALL
IMPORT
SIG · OBUG
O
obug
observabilityjavascriptv2.1.1
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.

createDebug
import { createDebug } from 'obug'
const createDebug = require('obug').createDebug
v2 refactored API imports, use named exports for ESM.
disable
import { disable } from 'obug'
const disable = require('obug').disable
v2 refactored API imports, use named exports for ESM.
namespaces
import { namespaces } from 'obug'
const namespaces = require('obug').namespaces
v2 refactored API imports, use named exports for ESM.

Demonstrates `obug` installation, creating debuggers, enabling/disabling namespaces, and using sub-namespaces.

import { createDebug, disable, enable, enabled, namespaces } from 'obug'; // Enable debug messages for 'my-namespace' and its sub-namespaces enable('my-namespace*'); // Get the currently enabled namespaces console.log('Enabled namespaces:', namespaces()); const debug = createDebug('my-namespace', { // All options are optional useColors: true, // false, true, undefined for auto-detect color: 2, // custom color (e.g., ANSI color code) // custom formatArgs (Node.js only) formatArgs(args) { // Example: prepend a timestamp args[0] = `[${new Date().toISOString()}] ${args[0]}`; }, formatters: {}, // custom formatters (like debug.formatters) // Node.js only options inspectOpts: { depth: 4 }, // custom log function log: console.log, }); // This message will be logged because 'my-namespace' is enabled debug('This is a debug message for %s', 'my-component'); console.log( 'Namespace:', debug.namespace, // 'my-namespace' 'Enabled:', debug.enabled, // true 'Using colors:', debug.useColors, // true ); // Create a sub-namespace, inheriting options from the parent const sub = debug.extend('sub-namespace'); sub('This is a sub-namespace debug message with an object: %o', { id: 123, status: 'active' }); console.log('Sub-namespace:', sub.namespace); // 'my-namespace:sub-namespace' // Example of disabling debug messages disable('my-namespace*'); console.log('Enabled after disable:', enabled('my-namespace')); // Should be false or empty const debug2 = createDebug('another-namespace'); debug2('This message will NOT appear because its namespace is not enabled.');
Debug
Known issues
breakingobug v2 introduced a significant rewrite that refactors API imports and usage compared to v1. Direct replacements for `debug`'s default export might not work without modification.
fix
Update all import statements to use named exports (e.g., `import { createDebug } from 'obug'`) instead of relying on a default export or a CommonJS-style `require('obug')` that returns a function.
affects: >=2.0.0
gotchaobug drops support for older browsers and Node.js versions compared to the original `debug` package, specifically targeting ES2015+ environments.
fix
Ensure your project's target environment supports ES2015+ features (e.g., modern browsers, Node.js 14+). If targeting older runtimes, consider using the original `debug` package or transpiling your code.
affects: >=1.0.0
gotchaobug is designed with native ES Module (ESM) compatibility in mind. Using CommonJS `require()` in an ESM context or a mixed environment without proper configuration can lead to import issues.
fix
Prefer `import ... from 'obug'` syntax. If using CommonJS, ensure your build setup correctly handles ESM imports or configure Node.js with `--experimental-loader esm` (though named imports are still the preferred way).
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: obug is not a function
Attempting to call the top-level `obug` module as a function (similar to `require('debug')('namespace')`) in an ESM context, or incorrectly importing the default export.
fix
Use the named export `createDebug` explicitly: `import { createDebug } from 'obug'; const debug = createDebug('my-namespace');`
TypeError: Cannot read properties of undefined (reading 'createDebug')
Incorrectly trying to destructure `createDebug` from a CommonJS `require('obug')` that doesn't expose it this way, or a typo in the named import.
fix
Ensure you are using `import { createDebug } from 'obug';` for ESM, and verify that your environment is properly configured for ESM. If strictly in CJS, you may need a bundler to resolve the ESM module correctly.
ReferenceError: exports is not defined in ES module scope
Attempting to use CommonJS-specific globals (`exports`, `module.exports`, `require`) within an ES Module file (`.mjs` or `type: "module"` in `package.json`).
fix
Convert your module to use ES Module syntax (`import`/`export`). `obug` is built for ESM, and mixing CJS patterns can lead to errors.
Upgrade
Version history
2.1.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
obug — npm install obug · libregistry