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.

Then restart the TypeScript server.

Your original import can remain unchanged:

javascript
import 'mapbox-gl/dist/mapbox-gl.css'

You don't need to move the CSS file into your own src directory.

Frequently Asked Questions

Why does TypeScript say it cannot find a CSS file that exists?

Because TypeScript needs to resolve the import through its module/type system. The fact that the CSS file exists on disk doesn't automatically provide TypeScript with a module declaration for it.

Adding:

javascript
declare module '*.css' {}

tells TypeScript how to treat CSS modules.

Do I need @types/mapbox-gl to fix this error?

Not for the CSS declaration itself.

Share:

More in Technology

View category