---
url: https://masyaka.github.io/injecute/errors/no-previous-definition.md
description: A service depends on itself but there is nothing to decorate
---

# `INJECUTE_NO_PREVIOUS_DEFINITION`

**A service depends on itself but there is nothing to decorate.**

## How to fix it

A dependency on the key being registered resolves its previous definition (the replaced one, or the parent one). Register the original service first.

## Handling it in code

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

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

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