# Angular: NullInjectorError: No provider for HttpClient! — provideHttpClient() missing

**Code:** `NullInjectorError: No provider for HttpClient!` · **Category:** Angular · **Seen on:** Angular, TypeScript

A service or component injects `HttpClient`, but HTTP support was never added to the app's providers.

## Meaning

`HttpClient` is not provided by default. Standalone apps call `provideHttpClient()` in `bootstrapApplication` / `app.config.ts`; NgModule apps import `HttpClientModule`. Tests also need `provideHttpClient()` plus `provideHttpClientTesting()`.

## Common causes

- `provideHttpClient()` missing in `app.config.ts` / bootstrap providers
- `HttpClientModule` not imported in the root NgModule
- Test without `HttpClientTestingModule` / `provideHttpClientTesting()`
- Provider added in a lazy module but injected elsewhere
- Library requiring HttpClient used before it is provided

## Quick fix

1. Add `provideHttpClient()` to the application config
2. NgModule: import `HttpClientModule` once in `AppModule`
3. In tests add `provideHttpClient()` and `provideHttpClientTesting()`

## Detailed fix by platform

### Angular

1. `export const appConfig: ApplicationConfig = { providers: [provideRouter(routes), provideHttpClient(withInterceptors([authInterceptor]))] };`
2. Tests: `TestBed.configureTestingModule({ providers: [provideHttpClient(), provideHttpClientTesting()] })`

## Code examples

### app.config.ts

```typescript
import { ApplicationConfig } from '@angular/core';
import { provideRouter } from '@angular/router';
import { provideHttpClient, withFetch } from '@angular/common/http';
import { routes } from './app.routes';

export const appConfig: ApplicationConfig = {
  providers: [provideRouter(routes), provideHttpClient(withFetch())],
};
```

## How to diagnose

1. **App type** — Standalone or NgModule?
2. **Tests** — TestBed has HTTP providers?
3. **Scope** — Provided where the service lives?

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