Do the following checks, maybe this will sort it out:
Case Sensitivity: Make sure your folder is actually named components
(all lowercase). If it’s named components
but you’re importing it as @/Components/NavBar
(with a capital C
), that will break. Try updating your import to:
import { NavBar } from "@/components/NavBar"; // lowercase "components"
Check Your tsconfig.json
: If you're using the @
alias, check your tsconfig.json
file to make sure it includes this under compilerOptions
:
"paths": {
"@/*": ["./*"]
}
This configuration ensures TypeScript can resolve paths starting with @/
. If it’s not there, add it, save, and restart your TypeScript server. (In VS Code, press Ctrl+Shift+P
and search for TypeScript: Restart TS Server.)
File Location: Double-check that NavBar.tsx
exists exactly where you’re pointing to. It should be inside a folder named components
at the root (or wherever your alias resolves). Also, make sure there are no typos in the file name, and it’s using the correct extension (.tsx
or .js
).
Clear the Cache: If everything looks fine and it’s still not working, try restarting your Next.js server and clearing the cache. Run:
npm run dev -- --reset-cache
Hopefully, one of these steps fixes the issue! Let me know how it goes! 😊