Registry / devops / indx
library0.0.6jsnpmunverified

The `indx` package offers a minimalist utility for Node.js environments, designed to recursively load JavaScript and CoffeeScript files from a specified directory into a single object. It emulates the functionality of Ruby's `require_tree` directive, simplifying the aggregation of modules, particularly for architectural patterns like adapters where numerous small files need to be exposed collectively. The current stable version is `0.2.3`. However, the package has not seen updates in approximately nine years, indicating it is an abandoned project. It exclusively supports CommonJS module syntax and requires subfolders to explicitly contain an `index.js` or `index.coffee` file for them to be included. Due to its age and lack of ongoing maintenance, `indx` may not be compatible with modern Node.js features or best practices, including ES modules.

npm install indx
INSTALL
IMPORT
SIG · INDX
I
indx
devopsjavascriptv0.0.6
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.

indxFunction
const indx = require('indx');
import indx from 'indx';
This package is CommonJS-only and does not support ES module `import` syntax.
loadDirectory
const adapters = require('indx')('./adapters');
const adapters = indx.load('./adapters');
`indx` is a function that immediately takes the path argument, not an object with a method.
loadCurrentDirectory
module.exports = require('indx')(__dirname);
module.exports = require('indx')();
The function must be called with a path, typically `__dirname` for the current directory.

Demonstrates how to recursively load all JavaScript and CoffeeScript files from a directory into an object, respecting subfolder indexing.

const indx = require('indx'); const path = require('path'); // Create a dummy directory structure for demonstration require('fs').mkdirSync(path.join(__dirname, 'adapters'), { recursive: true }); require('fs').writeFileSync(path.join(__dirname, 'adapters', 'adapterA.js'), 'module.exports = { name: "Adapter A" };'); require('fs').writeFileSync(path.join(__dirname, 'adapters', 'adapterB.coffee'), 'module.exports = { name: "Adapter B (Coffee)" }'); // Note: Requires 'coffeescript' to be installed require('fs').mkdirSync(path.join(__dirname, 'adapters', 'sub_adapters'), { recursive: true }); require('fs').writeFileSync(path.join(__dirname, 'adapters', 'sub_adapters', 'index.js'), 'module.exports = require(\'indx\')(__dirname);'); require('fs').writeFileSync(path.join(__dirname, 'adapters', 'sub_adapters', 'adapterC.js'), 'module.exports = { name: "Adapter C" };'); // Load all adapters from the 'adapters' directory const allAdapters = indx(path.join(__dirname, 'adapters')); console.log('Loaded Adapters:', allAdapters); // Expected output: { adapterA: { name: 'Adapter A' }, adapterB: { name: 'Adapter B (Coffee)' }, subAdapters: { adapterC: { name: 'Adapter C' } } } // Clean up dummy files (optional) // require('fs').rmSync(path.join(__dirname, 'adapters'), { recursive: true, force: true });
Debug
Known issues
breakingPrior to v0.2.2, errors encountered during module loading were logged to the console. Since v0.2.2, `indx` now throws errors with a full stack trace, which can alter error handling logic.
fix
Ensure your error handling mechanisms are prepared to catch thrown exceptions rather than relying on console output.
affects: <0.2.2
gotchaIndx only processes `.js` and `.coffee` files. Any other file types within the target directories will be ignored and not included in the resulting object.
fix
Rename files to `.js` or `.coffee` if they are intended to be loaded by `indx`, or use an alternative loading mechanism for other file types.
affects: >=0.1.0
gotchaFor `indx` to recursively load modules from subdirectories, each subfolder must contain an `index.js` or `index.coffee` file at its root, which in turn calls `require('indx')(__dirname)`.
fix
Ensure all subdirectories intended for recursive loading have a proper `index.js` or `index.coffee` file configured as described in the usage.
affects: >=0.1.0
gotchaThe project is explicitly noted as 'in development' with 'versioning a little different', and has been abandoned for approximately nine years. This implies a lack of active maintenance, potential incompatibility with modern Node.js versions, and no expectation of new features or bug fixes.
fix
Consider using a more actively maintained and modern solution for directory-based module loading, especially for new projects. If using `indx`, be prepared for potential compatibility issues.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'coffeescript' (or similar syntax error related to CoffeeScript)
`indx` supports CoffeeScript files, but requires the `coffeescript` package to be installed as a peer dependency for them to be processed.
fix
Install the `coffeescript` package: `npm install coffeescript`
Object returned by indx is missing expected files from a subdirectory.
Subdirectories will only be processed by `indx` if they contain an `index.js` or `index.coffee` file that itself calls `require('indx')(__dirname)`.
fix
Add an `index.js` or `index.coffee` file to the root of each subdirectory you wish to include, containing `module.exports = require('indx')(__dirname);`.
Expected module not found in the loaded object (e.g., `allAdapters.myFile` is undefined).
`indx` only loads `.js` and `.coffee` files. Other file extensions are ignored.
fix
Ensure the file in question has a `.js` or `.coffee` extension.
SyntaxError: Cannot use import statement outside a module
`indx` is a CommonJS module and cannot be directly imported using ES module `import` syntax in an ES module context.
fix
Use CommonJS `require()` syntax (e.g., `const indx = require('indx');`). If your project is pure ESM, you may need a wrapper or a different library.
Upgrade
Version history
0.0.6latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
indx — npm install indx · libregistry