[Solved] "Cannot find module *.json" TypeScript Error
May 28, 2023
Because TypeScript does not support resolving JSON files by default. When trying to import a JSON file in the TypeScript project, may see the following error.
Cannot find module '*.json'. Consider using '--resolveJsonModule' to import module with '.json' extension
How to solve this error.
Add the resolveJsonModule
directive under compilerOptions in tsconfig.json file.
Example:
{
"compilerOptions": {
"resolveJsonModule": true,
}
}