Avatar ·

How to properly import a JSON file in TypeScript? "Cannot find module" error

Hello everyone! I started learning TypeScript and encountered a problem when trying to import a JSON file. I have a configuration file `config.json`: ```json { "apiUrl": "https://api.example.com", "port": 3000, "debug": true } ``` And I'm trying to import it in my TypeScript file `app.ts`: ```typescript import config from './config.json'; console.log(config.apiUrl); ``` But I get a compiler error: > "Cannot find module './config.json'. Consider using '--resolveJsonModule' to import module with '.json' extension." I'm using TypeScript 4.9.5. I tried adding `"resolveJsonModule": true` to `tsconfig.json`, but it didn't help. Maybe I'm doing something wrong? How to properly import JSON files in TypeScript? Do I need to install any additional packages?