When using *ngIf in a very simple component, I get the error in the title. For example, below code and app.module cause this:
app.component.html:
<ng-container *ngIf="true">
<div>True</div>
</ng-container>
app.module.ts:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
I am very confused as to what could be causing this. *ngFor directive has the same problem.
The rest of the project comes directly from ng new
generated files.
"@angular/core": "~11.2.8"
A corrupted or otherwise weird node_modules
is most likely the source of the problem.
Running npm ci
fixes the problem.