Asegúrese de que el paquete @angular/animations esté instalado (por ejemplo, ejecutando npm install @angular/animations ). Luego, en tu app.module.ts
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; @NgModule({ ..., imports: [ ..., BrowserAnimationsModule ], ... })Este mensaje de error suele ser engañoso .
Es posible que haya olvidado importar BrowserAnimationsModule . Pero ese no era mi problema . Estaba importando BrowserAnimationsModule en el AppModule raíz, como todos deberían hacer.
El problema era algo completamente ajeno al módulo. Estaba animando un *ngIf en la plantilla del componente, pero olvidé mencionarlo en @Component.animations para la clase del componente .
@Component({ selector: '...', templateUrl: './...', animations: [myNgIfAnimation] // <-- Don't forget! }) Si usa una animación en una plantilla, también debe incluir esa animación en los metadatos de animations del componente... cada vez .
Me encontré con problemas similares cuando traté de usar BrowserAnimationsModule . Los siguientes pasos resolvieron mi problema:
npm cache cleanSi experimenta un error 404 como
http://.../node_modules/@angular/platform-browser/bundles/platform-browser.umd.js/animations agregue las siguientes entradas para map en su system.config.js :
'@angular/animations': 'node_modules/@angular/animations/bundles/animations.umd.min.js', '@angular/animations/browser':'node_modules/@angular/animations/bundles/animations-browser.umd.js', '@angular/platform-browser/animations': 'node_modules/@angular/platform-browser/bundles/platform-browser-animations.umd.js'naveedahmed1 proporcionó la solución a este problema de github .