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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With