• Error
  • Reported by the type checker

TS2882

Cannot find module or type declarations for side-effect import of '{0}'.

A side-effect import (import "x") names a module that can't be resolved. Fix the path or install the package.

What it means

An import "x" statement with no bindings still has to resolve to a module. The module couldn't be found, either as a file or a package.

Example

index.ts
import "./missing-setup";
export {};
ts-r-check -p tsconfig.json --pretty false ts-r output
index.ts(1,8): error TS2882: Cannot find module or type declarations for side-effect import of './missing-setup'.

Recorded by node scripts/verify-examples.mjs with ts-r built from commit 6deaf01. The example uses the default tsconfig: strict, target: es2022, module: esnext, moduleResolution: bundler.

How to fix

  • Fix the path or the package name.
  • Install the package if it's missing.
  • For non-code imports such as CSS, declare them in a .d.ts, for example declare module "*.css";.