css file import error #84317
-
SummaryMy codebase started to throw css import error, although the css still works but how can I remove this error message? this even happens when I create a fresh nextjs project. I have not made any changes in codebase. but recently I updated node.js to v22 from v20. this might be the reason? Additional informationlayout.tsx
import '@/assets/styles/index.css'; error message
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 14 replies
-
Create a file named globals.d.ts (or css.d.ts) in the src folder or in the root directory of the project. Add: declare module '*.css'; Explanation: this tells TypeScript that any import ending in .css is a valid module. |
Beta Was this translation helpful? Give feedback.
-
Using node 22.18.0 and a fresh create-next-app, I can't reproduce this. What steps did you follow when creating the create-next-app? |
Beta Was this translation helpful? Give feedback.
Likely that your editor is not picking up the project's TS version, but the version it has built-in. If its VSCode, this link should help https://nextjs.org/docs/app/api-reference/config/typescript#ide-plugin