Angular StaticInjector error in production only

227 Views Asked by At

When I try and run the prod build I get this error ERROR NullInjectorError: StaticInjectorError(l)[u -> t]:. When I try ng serve --prod --optimization=false the error becomes ERROR NullInjectorError: StaticInjectorError(AppModule)[NgxSpinnerComponent -> NgxSpinnerService]. I have however added NgXSpinnerModule to imports in my app.module.ts and am not sure what to do at this point. If I use ng serve like normal everything works fine.

2

There are 2 best solutions below

0
On BEST ANSWER

Whatever version of ngx spinner you use needs to match your version of angular.

0
On

import { NgxSpinnerService } from "ngx-spinner";

constructor( private spinner: NgxSpinnerService )

Add these in your component and then use spinner in your component