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 ng build
command in the Angular CLI.
The TypeScript file for my component: my-component.ts
...
import credentials from './config/credentials.json';
export class MyComponent implements OnInit {
...
// Properties
username: string = credentials.username;
...
}
The JSON config file, stored at the location '/config': credentials.json
{
"credentials" : {
"username" : "my_user_name",
...
}
}
I am getting the error: Error: Should not import the named export 'credentials' (imported as 'credentials') from default-exporting module (only default export is available soon)
What is causing this error? It seems similar to the issue described here.