{"id":15096,"library":"dependable","title":"Dependable Dependency Injection Framework","description":"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.","status":"maintenance","version":"1.1.0","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/Schoonology/dependable","tags":["javascript"],"install":[{"cmd":"npm install dependable","lang":"bash","label":"npm"},{"cmd":"yarn add dependable","lang":"bash","label":"yarn"},{"cmd":"pnpm add dependable","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is primarily CommonJS. Direct ESM `import` statements may lead to issues or require specific Node.js interop configurations.","wrong":"import dependable from 'dependable';","symbol":"dependable","correct":"const dependable = require('dependable');"},{"note":"The `container` factory is accessed as a method on the default CommonJS export of the `dependable` module.","wrong":"import { container } from 'dependable';","symbol":"container","correct":"const container = dependable.container();"},{"note":"Used for registering dependencies. Dependencies can be functions (with arguments for auto-injection) or plain objects/values.","symbol":"register","correct":"container.register('myService', myServiceFunction);"},{"note":"The primary method for resolving and injecting dependencies into a consumer function.","symbol":"resolve","correct":"container.resolve(function (myService) { /* ... */ });"}],"quickstart":{"code":"const dependable = require('dependable');\nconst container = dependable.container();\n\n// Register simple dependencies\ncontainer.register('occupation', 'tax attorney');\ncontainer.register('transport', {\n  type: 'station wagon',\n  material: 'wood-paneled'\n});\n\n// Register a dependency that has other dependencies\ncontainer.register('song', function (occupation, transport, legalStatus) {\n  const song = {};\n  song.chorus = function chorus() {\n    return [\n      'I\\'m a ' + occupation,\n      'On a ' + transport.material + ' ' + transport.type + ' I ride',\n      'And I\\'m ' + legalStatus.message\n    ].join('\\n');\n  };\n  return song;\n});\n\n// Register a dependency out-of-order (lazy resolution)\ncontainer.register('legalStatus', {\n  warrants: [],\n  message: 'without outstanding warrants'\n});\n\n// Resolve and use a dependency\ncontainer.resolve(function (song) {\n  console.log('Original song:\\n' + song.chorus());\n});\n\n// Re-register dependencies for updated behavior (e.g., for testing)\ncontainer.register('occupation', 'cowboy');\ncontainer.register('legalStatus', {\n  warrants: [\n    {\n      for: 'shooting the sheriff',\n      notes: 'did not shoot the deputy'\n    }\n  ],\n  message: 'wanted: dead or alive'\n});\n\n// Resolve with updated dependencies (empty override to force re-evaluation)\ncontainer.resolve({}, function (song) {\n  console.log('\\nUpdated song:\\n' + song.chorus());\n});\n\n// Override dependencies at resolve time\nconst horse = {\n  type: 'horse',\n  material: 'steel'\n};\n\ncontainer.resolve({ transport: horse }, function (song) {\n  console.log('\\nOverride transport song:\\n' + song.chorus());\n});","lang":"javascript","description":"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."},"warnings":[{"fix":"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.","message":"This package is primarily designed for CommonJS (`require()`) environments. While Node.js offers some interoperability, using native ESM `import` statements directly with `dependable` may require specific configurations or lead to unexpected behavior, especially when dealing with other ESM-only dependencies.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Manually register dependencies from subdirectories or implement a custom recursive file loader if deep scanning is necessary.","message":"The `container.load(fileOrFolder)` method explicitly states it 'Does not traverse subdirectories.' This means it will only load files directly within the specified folder, which can be a limitation for larger applications with nested dependency structures, requiring manual registration or a custom loading mechanism for such cases.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"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.","message":"Dependable's minimalist design does not natively support asynchronous dependency resolution. If your dependencies require asynchronous initialization (e.g., fetching configuration, connecting to a database), you'll need to handle the asynchronous logic externally before registering the resolved dependency or design your functions to accept promises and resolve them manually outside the container's direct control.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"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.","message":"As with any dependency injection system, introducing circular dependencies can lead to unexpected behavior or runtime errors, even with lazy resolution. Dependable doesn't provide explicit mechanisms for detecting or breaking circular dependencies, which might complicate debugging in complex applications.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"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.","message":"The package has seen very limited active development since its initial release, with its core version remaining at 1.1.0 for a long period, despite minor recent commits on GitHub. This indicates minimal ongoing maintenance, which could pose a risk for long-term project viability, security updates, or compatibility with newer Node.js versions or ecosystem changes.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Ensure `container.register('someDependency', valueOrFunction)` is called before `container.resolve()` or `container.get()` attempts to use it.","cause":"Attempting to resolve a dependency that has not been registered in the container.","error":"Error: Dependency 'someDependency' not found"},{"fix":"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.","cause":"The `dependable` module was imported incorrectly, or Node.js's CommonJS/ESM interop failed to expose the default export as expected.","error":"TypeError: dependable.container is not a function"},{"fix":"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.","cause":"This error typically occurs in a CommonJS module when attempting to `require()` an npm package that has switched to being ESM-only.","error":"ERR_REQUIRE_ESM"}],"ecosystem":"npm"}