Skip to content

Commit c7357bf

Browse files
committed
docs: fix the cause of the missing ɵprov definition error on the NG0204 page
The page said `Token X is missing a ɵprov definition` happens when an `InjectionToken` is used without a provider, but that case throws NG0201. The error comes from a provider object for the token that has no `useValue`, `useFactory`, `useExisting` or `useClass` key, such as `{provide: TOKEN}` or a misspelled `usevalue`, so Angular tries to create the token itself. Describe that cause and its fix.
1 parent 4044cef commit c7357bf

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎adev/src/content/reference/errors/NG0204.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ Ensure all constructor parameters either have providers configured or use `@Opti
5050
The error message includes details about which token could not be resolved:
5151

5252
- `Can't resolve all parameters for X: (?, ?, ?)` — The `?` marks indicate unresolvable parameters. Check that the class has `@Service` or `@Injectable()` and all dependencies have providers.
53-
- `Token X is missing a ɵprov definition` — An `InjectionToken` was used without configuring a provider. Register the token with a value using `{provide: TOKEN, useValue: ...}` or add a default factory to the token definition.
53+
- `Token X is missing a ɵprov definition` — A provider for an `InjectionToken` has no `useValue`, `useFactory`, `useExisting`, or `useClass` key (for example, `{provide: TOKEN}` or a misspelled key such as `usevalue`), so Angular tries to create the token itself. Fix the provider, for example `{provide: TOKEN, useValue: ...}`.
5454

5555
Work backwards from the error's stack trace to identify where the problematic injection occurs, then verify that:
5656

5757
1. The class has a `@Service` or `@Injectable()` decorator
5858
2. All constructor parameters have registered providers
59-
3. Any `InjectionToken` has a configured provider or default value
59+
3. Any provider for an `InjectionToken` uses `useValue`, `useFactory`, `useExisting`, or `useClass`

0 commit comments

Comments
 (0)