I\'m getting following error when I build the Angular app using \"ng build --prod\". This is working when I build with Angular 4 and getting error with Angular 5. With Angul
Angular 5 and specifically angular cli 1.5 has default ahead of time compilation turned on and it needs to know module for all components/pipes etc. that it finds in your project folder if you have some components that aren't declared in any module it will throw errors.
You can either declare TimeAgoPipe in some module:
@NgModule({
declarations: [TimeAgoPipe, ...]
})
export class AppModule {}// for example can be any other used module
or try running build without ahead of time compilation resulting code will work slower
ng build --prod --aot=false
third way if you don't use that pipe at all you can add it to excluded files in tsconfig.json
{
...
"exclude": [ "path/to/unused/component.ts", ... ]
}