Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Next.js: "Cannot find module or type declarations for side-effect import of './globals.css'" ts(2882)

I just created a Next.js project using npx create-next-app.

Today, I opened my Next.js projects in VS Code and all of the .css imports suddenly start showing this error:

Cannot find module or type declarations for side-effect import of './globals.css' ts(2882)

This happens even on newly created Next.js projects.

I did not update any code or dependencies manually before this issue started. I also tried downgrading TypeScript, but the error persists.

Why is this error suddenly happening, and how can I fix it?

like image 703
octave Nkurunziza Avatar asked Nov 22 '25 05:11

octave Nkurunziza


1 Answers

Open any .tsx file. Press Ctrl + Shift + p and type: TypeScript: Select TypeScript version After that, select workspace version. It will search your node_modules for your lib and select it. The error will disappear.

- Guilherme on Sep 29 at 23:47

like image 69
2 revs, 2 users 80%Dharman Avatar answered Nov 24 '25 23:11

2 revs, 2 users 80%Dharman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!