TS2882
TypeScriptERRORNotableTypeHIGH confidence
Cannot find module or type declarations for side-effect import of 'X'.
Production Risk
Build will fail; resolve before shipping.
What this means
A type-checking error (TS2882): Cannot find module or type declarations for side-effect import of 'X'.. This diagnostic is emitted by the TypeScript compiler when cannot find module or type declarations for side-effect import of 'X'..
Why it happens
- 1The module path is incorrect or the package is not installed
- 2Missing @types/* declaration package
How to reproduce
TypeScript compiler reports TS2882 during type checking.
trigger — this will error
trigger — this will error
// Triggers TS2882 // Cannot find module or type declarations for side-effect import of 'X'.
expected output
error TS2882: Cannot find module or type declarations for side-effect import of 'X'.
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