Globhy
AllBusinessHealthMarketingTechnologyTravelUncategorized
HAHartanto3 views
Posted on 03 Sep 2026Edited on 03 Sep 2026

Share:

How to Fix "Cannot Find Module or Type Declarations for Side-Effect Import" in TypeScript

How to Fix "Cannot Find Module or Type Declarations for Side-Effect Import" in TypeScript

Learn how to fix the TypeScript TS2882 error for CSS imports, understand noUncheckedSideEffectImports, and use declare module '*.css' in Next.js.

  • You have only a few CSS imports.
  • You want stricter module declarations.
  • You want TypeScript to catch more invalid CSS paths.
  • You are maintaining a library with carefully controlled imports.

For a typical Next.js application with multiple third-party packages, however, the wildcard approach is generally more convenient.

Recommended Configuration for Next.js

If you're using Next.js and encounter:

javascript
TS2882: Cannot find module or type declarations for side-effect import

and the problematic import is a CSS file, start with:

global.d.ts

javascript
declare module '*.css' {}

Then make sure the file is included in your TypeScript project.

For example:

tsconfig.json

javascript
{
"include": [
"global.d.ts",
"src/**/*.ts",
"src/**/*.tsx"
]
}

Share:

More in Technology

View category