Help with nextjs.org/learn/dashboard-app global.css import

Hello, I am new to this community. If this is in the wrong place, I apologize and if this has been answered here (and I somehow didn’t see it) I apologize in advance.

I am learning Next.js and I am following the nextjs.org/learn tutorial. My issue is on this chapter: CSS Styling.

Problem

As I am following this tutorial, I am getting this error in VS Code when trying to import the global.css file:

Error: Cannot find module or type declarations for side-effect import of ‘@/app/ui/global.css’.

This error is only showing in VS Code, but the project seems to run fine when running the pnpm dev command.

Edit: I am also noticing this error on the global.css file: “Unknown at rule @tailwind

Steps to Reproduce

  1. Installed pnpm
  2. Created Next.js app:
npx create-next-app@latest nextjs-dashboard --example "https://github.com/vercel/next-learn/tree/main/dashboard/starter-example" --use-pnpm
  1. Started dev server: pnpm dev
  2. Added global CSS to app/layout.tsx:
import '@/app/ui/global.css'

Current Behavior

However, dev server is running and shows correct layout and updated css. (I had tried to ignore this and continue moving through next few chapters, since “if it ain’t broke, don’t fix it”)

Tailwind error screenshot:

This is a common VS Code/TypeScript warning that doesn’t affect your app’s functionality. Since your app runs correctly, you can safely continue with the tutorial.

To fix the VS Code warning, you have a few options:

  • Create a file called app.d.ts in your project root with: declare module '*.css';
  • Or add to your tsconfig.json under compilerOptions: \types\: [\node\]
  • Or simply ignore it - many developers do since CSS imports work fine in Next.js

This happens because TypeScript doesn’t understand CSS imports by default, but Next.js handles them at build time. The Next.js TypeScript docs have more details if you’re curious!

Disregard. I realized I had made an error:

I had inadvertently installed a Nightly VSCode Extension, which was forcing VS Code to move to 6.0.0-dev

Once I had removed that extension, I am no longer having issues, it seems. Thank you for your assistance, regardless. Have a good day

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.