title: Using Angular environment variables in workspace libraries
body: <p>I am using <a href="https://github.com/angular/angular-cli/wiki/angular-workspace" rel="nofollow noreferrer">workspaces</a> concept of angular latest version(>6).</p>
  
  <p>The CLI can generate a project that is a <a href="https://github.com/angular/angular-cli/wiki/stories-create-library" rel="nofollow noreferrer">library</a> with a command like this: </p>
  
  <pre><code>ng generate library api
  </code></pre>
  
  <p>tsconfig.json of default app is like this</p>
  
  <pre><code>"paths": {
        "env": ["src/environments"],
        "api": [
          "dist/api"
        ],
  </code></pre>
  
  <p>After that I created one service named ApiService in api library like this but it's not working</p>
  
  <pre><code>import { Injectable } from '@angular/core';
  import { HttpClient } from '@angular/common/http';
  import { environment } from 'env';
  
  @Injectable()
  export class ApiService {
    constructor(private http: HttpClient) {}
  
    getApiUrl(){
      console.log("Hello Api Url"+environment.api_url)
  }
  }
  </code></pre>
  
  <p>Returns error when I build api library  using command <code>ng build api</code>:</p>
  
  <pre><code>BUILD ERROR
  error TS6059: File 'ROOT_APP_PATH/src/environments/environment.ts'
  is not under 'rootDir' 'ROOT_APP_PATH\projects\api\src'.
  'rootDir' is expected to contain all source files.
  </code></pre>
  
  <p>please help to resolve this error.</p>
  
  <p>Thanks in Advance. </p>