---
url: https://masyaka.github.io/injecute/errors/invalid-dependency.md
description: A dependency is not a key, optional(key), collect(tag) or a function
---

# `INJECUTE_INVALID_DEPENDENCY`

**A dependency is not a key, optional(key), collect(tag) or a function.**

## How to fix it

Dependencies are service keys, optional(key), collect(tag) with a tag made by createTag(), or functions that return the value.

## Handling it in code

```ts
import { InjecuteError } from 'injecute';

try {
  // ...
} catch (error) {
  if (error instanceof InjecuteError && error.code === 'INJECUTE_INVALID_DEPENDENCY') {
    // error.message explains what happened; error.path is the resolution chain
  }
}
```

[All error codes](./index.md)
