Cannot find module or type declarations for side-effect import of './globals.css'. #194524
Replies: 4 comments 2 replies
-
|
This usually happens when TypeScript can’t resolve the global CSS import even though A few things to check: |
Beta Was this translation helpful? Give feedback.
-
|
One thing nobody mentioned that actually fixes this in a lot of cases is adding a CSS type declaration file manually. Create a file called declare module '*.css';Then make sure your {
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "custom.d.ts"]
}Also worth checking since you're on Vercel specifically, if the app is actually building and deploying fine but the error only shows in your editor, it's just the TypeScript language server being confused rather than a real build error. Restarting the TS server in VS Code with If the build itself is failing on Vercel, check your |
Beta Was this translation helpful? Give feedback.
-
|
TypeScript can’t resolve CSS module declarations during type checking, even though the file exists and the app runs fine locally. Restart TypeScript and Rebuild it The app usually still works at runtime; it’s primarily a TypeScript resolution issue. |
Beta Was this translation helpful? Give feedback.
-
|
The answers above cover the most common fixes, but let me add a more complete diagnosis since you mentioned this is on Vercel specifically. Most likely cause:
|
| Check | What to look for |
|---|---|
next-env.d.ts exists in repo root |
Must be committed, not gitignored |
tsconfig.json includes "moduleResolution": "bundler" |
Required for Next.js 13+ App Router |
globals.css is inside app/ directory |
Must be in the same folder as layout.tsx |
next-env.d.ts is included in tsconfig.json "include" |
Should be ["next-env.d.ts", "**/*.ts", "**/*.tsx"] |
If the Vercel build succeeds but the error only appears in your editor locally, it is just the TypeScript language server being out of sync — run Ctrl+Shift+P → TypeScript: Restart TS Server in VS Code to clear it.
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
🏷️ Discussion Type
Bug
Body
i have nextjs app deployed on vercel, app/layout.tsx shows "Cannot find module or type declarations for side-effect import of './globals.css'." , i do have this file
Guidelines
Beta Was this translation helpful? Give feedback.
All reactions