title: Angular 8 : No provider for HttpClient in service
body: <p>In order to migrate an Angular 5 project to Angular 8, I've created an empty project with Angular CLI and copied my modules, components and services in my new project structure.
  The project builds, but at the execution I've got the classic message "No provider for HttpClient in service" : </p>
  
  <pre><code>    ERROR NullInjectorError: StaticInjectorError(AppModule)[TimeService -&gt; HttpClient]: 
    StaticInjectorError(Platform: core)[TimeService -&gt; HttpClient]: 
      NullInjectorError: No provider for HttpClient!
      at NullInjector.get (http://localhost:4200/vendor.js:50573:27)
      at resolveToken (http://localhost:4200/vendor.js:52359:24)
      at tryResolveToken (http://localhost:4200/vendor.js:52285:16)
      at StaticInjector.get (http://localhost:4200/vendor.js:52148:20)
      at resolveToken (http://localhost:4200/vendor.js:52359:24)
      at tryResolveToken (http://localhost:4200/vendor.js:52285:16)
      at StaticInjector.get (http://localhost:4200/vendor.js:52148:20)
      at resolveNgModuleDep (http://localhost:4200/vendor.js:76198:29)
      at _createClass (http://localhost:4200/vendor.js:76275:32)
      at _createProviderInstance (http://localhost:4200/vendor.js:76231:26)
  </code></pre>
  
  <p>I thing my app.module.ts is ok : I'm importing HttpClientModule and I've put it in @NgModule imports, just after BrowserModule.</p>
  
  <pre><code>@NgModule({
      declarations: [AppComponent,DelegationsComponent],
      imports:      [BrowserModule,
                    HttpClientModule,
                    GlobalModule.forRoot(),
                    AuthenticationModule,
                     DelegationModule,
                     routing,
                     FormsModule,
                     ReactiveFormsModule,
                     BrowserAnimationsModule,
                     ButtonModule, TableModule, DialogModule, DropdownModule, ToastModule, TabViewModule, InputTextModule, AutoCompleteModule, TooltipModule, CheckboxModule, OverlayPanelModule, MultiSelectModule, CalendarModule ],
      providers:    [APP_ROUTER_PROVIDERS, {provide: APP_BASE_HREF, useValue: getBaseHref()}],
      bootstrap:    [AppComponent]
  })
  </code></pre>
  
  <p>The error seems to be in TimeService. In this service, HttpClient is imported and injected in the contructor. </p>
  
  <pre><code>import {HttpClient} from "@angular/common/http";
  
  @Injectable()
  export class TimeService extends BaseService {
      constructor(private http: HttpClient)
  </code></pre>
  
  <p>Then, TimeService is injected in DelegationsComponent.</p>
  
  <pre><code>import {TimeService} from "utils/time.service";
  @Component({
      moduleId: __moduleName,
      selector: 'delegations',
      templateUrl: './delegations.component.html'
  })
  export class DelegationsComponent implements OnInit, OnDestroy {
      constructor(private timeService: TimeService)
  </code></pre>
  
  <p>And you can see DelegationsComponent in my app.module.ts declarations.</p>
  
  <p>Any idea ?
  Thank you</p>
  
  <p><strong>EDIT :</strong> 
  By trying to reproduce the problem on a small example, I've found the cause : time.service.ts is not in my angular app but in a folder outside, because I'm sharing it with two other angular apps. I'm including it thanks to the package.json of my apps : </p>
  
  <pre><code>"utils": "file:../../../../../utils"
  </code></pre>
  
  <p>So time.service.ts ends in node_modules/utils. If I put it in the src/app directory, it works. Any idea why it doesn't work this way, and how I can share a service amongst several angular apps ?</p>