title: Build error 'Module not found' when importing local library in Angular
body: <p>I'm trying to generate a library for an api client auto-generated with Swagger and use it locally from within my app in Angular7, but I'm not able to make it work :-(</p>
  
  <p>The library is genererated and imported correctly in the app, no warnings / errors in VSCode, but when I run ng build command in the app it throws these errors:</p>
  
  <pre><code>ERROR in ./src/app/diary/diary-data.service.ts
  Module not found: Error: Can't resolve 'lib-diary-shoot-api-client/lib/api/api' in 'D:\DANI\vscode\dairy-shoot\src\app\diary'
  ERROR in ./src/app/app.module.ts
  Module not found: Error: Can't resolve 'lib-diary-shoot-api-client/public_api' in 'D:\DANI\vscode\dairy-shoot\src\app'
  </code></pre>
  
  <p>I have tried copying the api client auto-generated with Swagger into my app and it works perfectly, so I discard any problems with the code.</p>
  
  <p>I think it has to be something that I'm doing wrong or missing when encapsulating the code in the library or importing it manually from my app.</p>
  
  <p>I try to reproduce it step-by-step:</p>
  
  <ol>
  <li><p>Created the library with angular-cli</p></li>
  <li><p>Copied api client files into /lib folder</p></li>
  <li><p>Exported internal files in index.ts:</p></li>
  </ol>
  
  <pre><code>    export * from './api/api';
      export * from './model/models';
      export * from './variables';
      export * from './configuration';
      export * from './api.module';
  </code></pre>
  
  <ol start="4">
  <li><p>Generated library with angular-cli</p></li>
  <li><p>Copied the /dist/lib files into app</p></li>
  <li><p>Added the path for the library in app ts.config:</p></li>
  </ol>
  
  <pre><code>    "paths": {
        "lib-diary-shoot-api-client": [
          "./src/lib-diary-shoot-api-client"
        ]
      }
  </code></pre>
  
  <ol start="7">
  <li>Added the import in app.module:</li>
  </ol>
  
  <pre><code>    import { ApiModule } from 'lib-diary-shoot-api-client/public_api';
  </code></pre>
  
  <p>I really appreciate any help on this. I have followed many tutorials but almost all of them focus on npm publication instead of local use and they don't give many details on the later.</p>
  
  <p>Thanks in advance!</p>
  
  <hr>
  
  <p>EDIT 1: I have found that even with the sample library that ng-cli generates I get the same error when trying to import a service from the library in a service of the app.</p>
  
  <p>If I import the library module in the app module and put the library component tag in the app template it works, the page is rendered correctly with the "it works" message of the library component.</p>
  
  <p><strong>So it seems that the problem is only with services</strong>.</p>
  
  <p>Maybe there is a problem with the exports or injectors?</p>
  
  <p>The code looks fine with no warnings / errors in VSCode but when I run the ng build command it throws the same error as above:</p>
  
  <pre><code>ERROR in ./src/app/diary/diary.module.ts
  Module not found: Error: Can't resolve 'libs/diary-shoot-client-lib/public_api' in 'D:\DANI\vscode\dairy-shoot\src\app\diary'
  ERROR in ./src/app/diary/diary-data.service.ts
  Module not found: Error: Can't resolve 'libs/diary-shoot-client-lib/public_api' in 'D:\DANI\vscode\dairy-shoot\src\app\diary'
  </code></pre>
  
  <p>I have followed the official guides:</p>
  
  <p><a href="https://angular.io/guide/creating-libraries" rel="noreferrer">https://angular.io/guide/creating-libraries</a></p>
  
  <p><a href="https://github.com/angular/angular-cli/wiki/stories-create-library#using-your-library-inside-your-apps" rel="noreferrer">https://github.com/angular/angular-cli/wiki/stories-create-library#using-your-library-inside-your-apps</a></p>
  
  <p>Version of Angular CLI:</p>
  
  <pre><code>Angular CLI: 7.0.7
  Node: 8.11.0
  OS: win32 x64
  Angular: 7.0.4
  ... animations, common, compiler, compiler-cli, core, forms
  ... http, language-service, platform-browser
  ... platform-browser-dynamic, router
  
  Package                            Version
  ------------------------------------------------------------
  @angular-devkit/architect          0.10.7
  @angular-devkit/build-angular      0.10.7
  @angular-devkit/build-ng-packagr   0.10.7
  @angular-devkit/build-optimizer    0.10.7
  @angular-devkit/build-webpack      0.10.7
  @angular-devkit/core               7.0.7
  @angular-devkit/schematics         7.0.7
  @angular/cli                       7.0.7
  @ngtools/json-schema               1.1.0
  @ngtools/webpack                   7.0.7
  @schematics/angular                7.0.7
  @schematics/update                 0.10.7
  ng-packagr                         4.7.1
  rxjs                               6.3.3
  typescript                         3.1.6
  webpack                            4.19.1
  </code></pre>