Self-answered question for this error:
injector.ts:128 Uncaught Error: StaticInjectorError[Compiler]: StaticInjectorError[Compiler]: NullInjectorError: No provider for Compiler! at _NullInjector.get (injector.ts:23) [angular]
I had forgotten to import BrowserModule
into my main app module.
import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {RouterModule, Routes} from '@angular/router';
import {AppComponent} from './app';
...
@NgModule({
declarations: [
AppComponent, ...
],
imports: [
BrowserModule, // <-- this!
RouterModule.forRoot(routes),
],
bootstrap: [
AppComponent,
]
})
export class AppModule {}
If you only see this error during unit testing, see this question: Error: No provider for Compiler! DI Exception Angular 2 Testing
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With