Registry / testing / dir

dir

JSON →
library0.1.2jsnpmunverified

The `dir` package, version 0.1.2, provides a utility for Node.js to inspect objects in a 'Firebug-like' manner. Published over a decade ago, its primary goal was to offer more comprehensive object inspection, including prototype chain traversal, than Node.js's built-in `util.inspect` at the time. Unlike `util.inspect`, it aimed to return a real object for shell integration and better-colored output, even monkey-patching `console.dir`. The package has seen no updates since its initial release and is considered abandoned, with modern Node.js `console.dir` and `util.inspect` offering robust and actively maintained alternatives that supersede its original functionality. It is not compatible with modern ESM environments without additional tooling.

testing
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.

This package is a CommonJS module and must be imported using `require()` in Node.js environments. Direct ESM `import` statements will fail.

const dir = require('dir');

The package monkey-patches the global `console.dir` when `require('dir')` is executed. This behavior is specific to CommonJS and will not occur with ESM `import` statements.

require('dir'); console.dir(myObject);

Demonstrates importing the `dir` utility and using it for inspecting various JavaScript objects, including a custom class instance, a function, and a native Date object. It also shows the effect of its `console.dir` monkey-patch.

const dir = require('dir'); class MyClass { constructor(name) { this.name = name; this.version = '1.0'; } greet() { return `Hello, ${this.name}!`; } } const instance = new MyClass('World'); // Basic object inspection console.log('--- Inspecting a simple object ---'); dir(instance); // Inspecting a function console.log('\n--- Inspecting a function ---'); dir(instance.greet); // Inspecting a native object console.log('\n--- Inspecting a native object (Date) ---'); dir(new Date()); // The package also monkey-patches console.dir console.log('\n--- Using the monkey-patched console.dir ---'); console.dir({ a: 1, b: { c: 2, d: [3, 4] } });
Debug
Known footguns
breakingThis package is a legacy CommonJS module and is not compatible with Node.js ES Modules (ESM) without a CommonJS wrapper or specific build configurations (e.g., using `createRequire` or a bundler). Direct `import` statements will result in errors.
deprecatedThe `dir` package (v0.1.2) has been abandoned for over a decade. It lacks maintenance, security updates, and compatibility with modern JavaScript features or Node.js versions beyond its original release era. Its functionality is largely superseded by Node.js's built-in `console.dir()` and `util.inspect()` methods, which are actively maintained and more robust.
gotchaThe package monkey-patches the global `console.dir` function upon `require('dir')`. This global modification can lead to unexpected behavior or conflicts with other libraries that might also modify `console` methods, making debugging difficult or changing the behavior of other parts of your application.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
15 hits · last 30 days
gptbot
4
amazonbot
4
ahrefsbot
3
bytedance
2
script
1
googlebot
1
Resources