This error occurs when Angular cannot resolve a dependency for a class during dependency injection. This most commonly affects classes using constructor injection, where Angular relies on TypeScript metadata to determine parameter types.
The most common causes are:
- A service class is missing the
@Injectable()decorator - An
InjectionTokenlacks a proper provider definition - A constructor parameter cannot be resolved
NOTE: The inject() function takes an explicit token, so the "unresolvable parameter" scenario does not apply to it directly. However, if the injected class itself is missing @Injectable() and has its own constructor dependencies, the error can still occur.
Common scenarios
Missing @Injectable() decorator
When a class has constructor dependencies but lacks the @Injectable() decorator, Angular cannot resolve its parameters:
Missing @Injectable() decorator
export class UserClient { constructor(private http: HttpClient) {} // Angular can't resolve this}
Add the @Injectable() decorator to fix this:
@Injectable({providedIn: 'root'})export class UserClient { constructor(private http: HttpClient) {}}
Unresolvable constructor parameters
This error also appears when Angular cannot determine the type of a constructor parameter:
@Injectable({providedIn: 'root'})export class DataStore { // Angular can't resolve 'config' without a provider constructor(private config: AppConfig) {}}
Ensure all constructor parameters either have providers configured or use @Optional() for optional dependencies.
Debugging the error
The error message includes details about which token could not be resolved:
Can't resolve all parameters for X: (?, ?, ?)— The?marks indicate unresolvable parameters. Check that the class has@Injectable()and all dependencies have providers.Token X is missing a ɵprov definition— AnInjectionTokenwas used without configuring a provider. Register the token with a value using{provide: TOKEN, useValue: ...}or add a default factory to the token definition.
Work backwards from the error's stack trace to identify where the problematic injection occurs, then verify that:
- The class has
@Injectable()decorator - All constructor parameters have registered providers
- Any
InjectionTokenhas a configured provider or default value