NG8103 Angular Origin: On your device Angular 17+ Last updated 15 Oct 2026

Angular: NG8103: The *ngIf directive was used, but neither the NgIf directive nor the CommonModule was imported

A standalone component uses *ngIf, *ngFor or ngClass without importing the directive — or should migrate to the built-in @if / @for control flow.

Exact message you may see The *ngIf directive was used in the template, but neither the NgIf directive nor the CommonModule was importedThe *ngFor directive was used in the template, but neither the NgFor directive nor the CommonModule was importedneither the NgIf directive nor the CommonModule
Seen on: Angular TypeScript

Meaning

Standalone components do not get CommonModule for free. Either import the directive you use (NgIf, NgFor, NgClass) or move to the new block syntax (@if, @for, @switch), which needs no import at all.

Common causes

  • Standalone component using *ngIf / *ngFor / ngClass / ngStyle without importing them
  • Component generated as standalone but old templates pasted from an NgModule project
  • CommonModule removed from an NgModule that declares the component
  • Using NgFor syntax inside ng-template of another component without its import

⚡ Quick fix

  1. Replace with @if / @for (no imports)
  2. Or add NgIf, NgFor, NgClass to the component's imports
  3. Run the control-flow migration schematic

Detailed fix by platform

Angular CLI

  1. Migrate automatically: ng generate @angular/core:control-flow
  2. Manual: imports: [NgIf, NgFor] from @angular/common

Code examples

Built-in control flow

html
<!-- before: <li *ngFor="let u of users">{{ u.name }}</li> -->
@if (users.length) {
  <ul>
    @for (u of users; track u.id) {
      <li>{{ u.name }}</li>
    }
  </ul>
} @else {
  <p>No users yet</p>
}

How to diagnose

  1. Component — Standalone or in an NgModule?
  2. Directive — Which structural directive is used?
  3. Version — Angular 17+ (control flow available)?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

NG02200 — Angular: NG02200: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays (Angular)NG02200NG0301 — Angular: NG0301: Export of name 'x' not found! (template variable #x="exportAs") (Angular)NG0301NG0955 — Angular: NG0955: The provided track expression resulted in duplicated keys for a given collection (@for) (Angular)NG0955NG6008 — Angular: NG6008: Component X is standalone, and cannot be declared in an NgModule. Did you mean to import it instead? (Angular)NG6008NG8001 — Angular: NG8001: 'app-item' is not a known element — verify that it is included in the component's imports (Angular)NG8001NG8004 — Angular: NG8004: No pipe found with name 'async' / 'date' / 'translate' — pipe not imported (Angular)NG8004NG8113 — Angular: NG8113: NgIf is not used within the template of AppComponent — unused standalone import (Angular)NG8113NG8103

Explore the map of this error Full error map →

🧠 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.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.