# Angular: NG0201: No provider for X found in NodeInjector

**Code:** `NG0201` · **Category:** Angular · **Seen on:** Angular, TypeScript

A component or directive asked for a service no injector in its tree provides.

## Meaning

Unlike the older `NullInjectorError`, this message comes from the element injector (a component, directive or pipe). Provide the service with `providedIn: 'root'`, in the component's `providers`, or in the route/bootstrap providers.

## Common causes

- Service lacks `@Injectable({ providedIn: 'root' })` and is not in any `providers`
- Provider declared in a lazy-loaded module/route not covering this component
- A directive/pipe injecting a token that must be provided by its host (for example `NgControl`)
- Parent-only token injected with the wrong `@Host`/`@Optional` flags
- Test module without the required provider

## Quick fix

1. Add `providedIn: 'root'` or list the service in `providers`
2. Provide it at the right level (route, component or bootstrapApplication)
3. Add the provider to the TestBed in tests

## Detailed fix by platform

### Angular

1. `@Injectable({ providedIn: 'root' })` on the service
2. Bootstrap: `bootstrapApplication(AppComponent, { providers: [provideHttpClient()] })`

## Code examples

### Provide at the right level

```typescript
@Component({
  selector: 'app-cart',
  standalone: true,
  providers: [CartService],           // component-level instance
  template: `...`,
})
export class CartComponent { cart = inject(CartService); }
```

## How to diagnose

1. **Token** — Which service or token is named?
2. **Provider** — Where is it provided?
3. **Tree** — Is the component inside that provider's scope?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/angular/ng0201-no-provider-nodeinjector)
