I've been encountering an issue with importing JSON files into TypeScript. I've set up my tsconfig.json file following the standard conventions, but it's still not working in the environment.ts file. Interestingly enough, it works perfectly fine in the environment.prod.ts file.
environment.ts
import { domain, clientId, audience, serverUrl } from '../../auth_config.json';
export const environment = {
production: false,
auth: {
domain,
clientId,
redirectUri: window.location.origin,
audience,
},
dev: {
serverUrl,
},
};
ERROR --> Cannot find module '../../auth_config.json'. Consider using '--resolveJsonModule' to import a module with a '.json' extensionts(2732)
environment.prod.ts
import { domain, clientId, audience, serverUrl } from '../../auth_config.json';
export const environment = {
production: true,
auth: {
domain,
clientId,
redirectUri: window.location.origin,
audience,
},
dev: {
serverUrl,
},
};
It works okay.
This is my tsconfig.json configuration:
"files": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path"": "./tsconfig.spec.json"
}
],
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": [],
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"strict": true,
"resolveJsonModule": true,
"esModuleInterop": true
},
}
I've been stuck on this for several days now without any luck in finding a solution. Any help would be greatly appreciated. Thank you.