Angular: NullInjectorError: No provider for X!
Angular’s dependency injection couldn’t find a provider for a service/token the component needs.
Seen on:
Angular
Meaning
Common: HttpClient without provideHttpClient(), a service without providedIn: 'root', standalone components missing imports/providers, or injecting a service from a lazy module elsewhere.
Common causes
- provideHttpClient() missing (No provider for HttpClient)
- Service not providedIn root nor listed in providers
- Standalone component missing the provider/import
- Token used outside its injector scope
⚡ Quick fix
- Add provideHttpClient() in app.config.ts
- Use @Injectable({ providedIn: 'root' })
- Provide the service in the component/route providers
Detailed fix by platform
TypeScript
- typescript
export const appConfig: ApplicationConfig = { providers: [provideRouter(routes), provideHttpClient(withInterceptorsFromDi())] };
How to diagnose
- Token — Which provider is missing?
- Scope — Where is it provided?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- circular references The dependencies of some of the beans in the application context form a cycle
- InvalidOperationException InvalidOperationException: Unable to resolve service for type 'X' while attempting to activate 'Y'
- NG0100 Angular: NG0100: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked
Other ways to find it
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 7 Oct 2026