title: How to troubleshoot 'NullInjectorError: StaticInjectorError' in Angular 8 resolver
body: <p><strong>UPDATE:</strong> The problem is only present in development mode, and vanishes when running ng build or ng serve with the --prod flag. </p>
  
  <p>I've noticed a regression in a web app I'm working on after upgrading to Angular 8. In one of my components, I've started recieving this error:</p>
  
  <pre><code>ERROR Error: Uncaught (in promise): NullInjectorError: StaticInjectorError(AppModule)[function () { return []: 
    StaticInjectorError(Platform: core)[function () { return []: 
      NullInjectorError: No provider for function () { return [!
  Error: NullInjectorError: No provider for function () { return [!
      at NullInjector.push../node_modules/@angular/core/fesm5/core.js.NullInjector.get (core.js:725) [angular]
      at resolveToken (core.js:11812) [angular]
      at tryResolveToken (core.js:11756) [angular]
      at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:11660) [angular]
      at resolveToken (core.js:11812) [angular]
      at tryResolveToken (core.js:11756) [angular]
      at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:11660) [angular]
      at resolveNgModuleDep (core.js:20006) [angular]
      at NgModuleRef_.push../node_modules/@angular/core/fesm5/core.js.NgModuleRef_.get (core.js:20677) [angular]
      at getToken (router.js:2844) [angular]
      at getResolver (router.js:3492) [angular]
      at resolveNode (router.js:3475) [angular]
      at runResolve (router.js:3461) [angular]
      at MergeMapSubscriber.project (router.js:3455) [angular]
      at resolvePromise (zone.js:852) [angular]
      at resolvePromise (zone.js:809) [angular]
      at polyfills.js:3918:17 [angular]
      at Object.onInvokeTask (core.js:25977) [angular]
      at drainMicroTaskQueue (zone.js:601) [&lt;root&gt;]
  </code></pre>
  
  <p>I've narrowed the problem down to the resolver used in the route to the component. When I remove/comment out the injections from the constructor, the component loads fine. Any ideas what could be causing this? I'm stumped.</p>
  
  <p>Here's the resolver:</p>
  
  <pre class="lang-js prettyprint-override"><code>IMPORTS REMOVED FOR BREVITY
  
  @Injectable()
  export class MemberListResolver implements Resolve&lt;User[]&gt; {
    constructor(
      private authService: AuthService,
      private router: Router,
      private alertify: AlertifyService,
      private distributorService: DistributorService
    ) {
    }
  
    resolve(route: ActivatedRouteSnapshot): Observable&lt;User[]&gt; {
      return this.authService.currentDistributor.pipe(
        flatMap((d: Distributor) =&gt; {
          return this.distributorService.getUsers(d.id).pipe(
            catchError(error =&gt; {
              this.alertify.message('Problem retrieving users');
              this.router.navigate(['/home']);
              return of(null);
            })
          );
        })
      );
    }
  }
  </code></pre>