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.

TypeScript may report:

javascript
Cannot find module 'mapbox-gl/dist/mapbox-gl.css'
or its corresponding type declarations.

This doesn't necessarily mean that the CSS file doesn't exist.

In fact, if you've installed mapbox-gl, the file is normally located inside your node_modules directory:

javascript
node_modules/
└── mapbox-gl/
├── dist/
│ ├── mapbox-gl.js
│ └── mapbox-gl.css
└── package.json

The problem is that TypeScript needs to understand the imported module, while CSS files don't contain TypeScript type declarations.

This becomes particularly noticeable when noUncheckedSideEffectImports is enabled.

What Is a Side-Effect Import in TypeScript?

A side-effect import is an import statement that doesn't import a specific value.

For example:

javascript
import './styles.css'

There is no variable being imported:

Share:

More in Technology

View category