Dependable is a minimalist dependency injection (DI) framework specifically designed for Node.js environments. It currently stands at version 1.1.0, a stable release, but exhibits a very low release cadence, with the last significant update being a number of years ago, despite minor recent commits on its GitHub repository. Its core functionality revolves around automatic dependency resolution through function argument introspection, allowing for lazy loading of dependencies. Key differentiators include its simple API for registering and resolving dependencies, support for re-registering components (useful for configuration or mocking), and the ability to override dependencies at resolve time. Unlike more comprehensive modern DI containers like InversifyJS or Awilix, Dependable focuses purely on a lightweight, convention-based approach, omitting features such as explicit type binding, decorator-based configuration, or native asynchronous dependency resolution. This makes it suitable for projects prioritizing simplicity and minimal overhead.
npm install dependableVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a Dependable container, register various types of dependencies (strings, objects, functions with auto-injected arguments), and resolve them. It also shows how to re-register dependencies for dynamic changes and override them at the point of resolution for flexible behavior and testing.
Ensure your project uses CommonJS modules where `dependable` is imported, or use tools like `cjs-to-esm` to wrap the package if native ESM import is strictly required.
Manually register dependencies from subdirectories or implement a custom recursive file loader if deep scanning is necessary.
Resolve asynchronous dependencies before registering them as values or functions that return synchronous results. Alternatively, use a more modern DI framework that supports async resolution.
Carefully design your module structure to avoid direct or indirect circular dependencies. Refactor shared logic into separate modules that neither of the circularly dependent modules relies on.
Evaluate the long-term maintenance risk. For new projects or those requiring active support, consider more actively maintained DI frameworks. For existing projects, be prepared to fork or address compatibility issues independently.
Ensure `container.register('someDependency', valueOrFunction)` is called before `container.resolve()` or `container.get()` attempts to use it.Always use `const dependable = require('dependable');` for this CommonJS-first package. Avoid `import dependable from 'dependable';` unless your build pipeline or Node.js environment is configured to handle CJS default exports in ESM.While `dependable` itself is CJS, if one of your dependencies registered with `dependable` is ESM-only and you're trying to `require` it, this error might appear. Ensure all modules directly or indirectly `require`d in your CJS application are also CJS, or migrate your application to ESM if possible to leverage native ESM imports for ESM-only packages.
No dependency data recorded yet.