TS2732
TypeScriptERRORNotableTypeHIGH confidence
Cannot find module 'X'. Consider using '--resolveJsonModule' to import module...
Production Risk
Build will fail; resolve before shipping.
What this means
A type-checking error (TS2732): Cannot find module 'X'. Consider using '--resolveJsonModule' to import module with '.json' extension.. This diagnostic is emitted by the TypeScript compiler when cannot find module 'X'. Consider using '--resolveJsonModule' to import module with '.json' extension..
Why it happens
- 1The module path is incorrect or the package is not installed
- 2Missing @types/* declaration package
How to reproduce
TypeScript compiler reports TS2732 during type checking.
trigger — this will error
trigger — this will error
// Triggers TS2732 // Cannot find module 'X'. Consider using '--resolveJsonModule' to import module with '.json' extension.
expected output
error TS2732: Cannot find module 'X'. Consider using '--resolveJsonModule' to import module with '.json' extension.
Fix
Install the package and its type declarations
WHEN When a module cannot be found
Install the package and its type declarations
npm install my-package npm install --save-dev @types/my-package
Why this works
TypeScript resolves modules via node_modules; @types/* packages provide type declarations.
Sources
Official documentation ↗
TypeScript Compiler Diagnostics
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev