title: How do I read a local JSON file in Angular 12?
body: <p>I am trying to read data from a local JSON file, that stores some config data for my app. I keep getting an error when using the <code>ng build</code> <a href="https://angular.io/cli/build" rel="nofollow noreferrer">command in the Angular CLI</a>.</p>
  <p>The TypeScript file for my component: my-component.ts</p>
  <pre><code>...
  import credentials from './config/credentials.json';
  
  export class MyComponent implements OnInit {
      ...
      // Properties
      username: string = credentials.username;
      ...
  }
  </code></pre>
  <p>The JSON config file, stored at the location '/config': credentials.json</p>
  <pre><code>{
      &quot;credentials&quot; : {
          &quot;username&quot; : &quot;my_user_name&quot;,
          ...
      }
  }
  </code></pre>
  <p>I am getting the error: <code>Error: Should not import the named export 'credentials' (imported as 'credentials') from default-exporting module (only default export is available soon)</code></p>
  <p>What is causing this error? It seems similar to the <a href="https://github.com/angular/angular-cli/issues/20753" rel="nofollow noreferrer">issue described here</a>.</p>