I've been attempting to retrieve data from a local JSON file that holds configuration information for my application. Every time I run the ng build
command in the Angular CLI, I encounter an error.
The TypeScript document related to my component: my-component.ts
...
import credentials from './config/credentials.json';
export class MyComponent implements OnInit {
...
// Properties
username: string = credentials.username;
...
}
The JSON configuration file, located at '/config': credentials.json
{
"credentials" : {
"username" : "my_user_name",
...
}
}
The error message states:
Error: Should not import the named export 'credentials' (imported as 'credentials') from default-exporting module (only default export is available soon)
What could be causing this issue? It appears similar to the problem reported here.