Next.js Discord

Discord Forum

Regarding imports

Unanswered
sooperman posted this in #help-forum
Open in Discord
Hi, i have been building an application while i am importing the Components i am getting an error "Module not found: Can't resolve '@/components'" even though every thing is right..



import { fetchCars } from "@/utils";
import { HomeProps } from "@/types";
import { fuels, yearsOfProduction } from "@/constants";
import { CarCard, SearchBar, CustomFilter, Hero} from "@/components";
export default async function Home({ searchParams }: HomeProps) {
  const allCars = await fetchCars({
    // manufacturer: searchParams.manufacturer || "",
    // year: searchParams.year || 2022,
    // fuel: searchParams.fuel || "",
    // limit: searchParams.limit || 10,


here is the code of that

15 Replies

@sooperman is this a vercel issue?
Nope nextjs issue...! @Arinji
Can you show your folder structure
Your import alias might just be fucked, can you try relative methods instead first?
So like use ../../ till you reach your folder
I tried but it doesn't work
Open your components folder please
yup
Send a screenshot
import { CarCard, SearchBar, CustomFilter, Hero} from "@/components";


This code means either:
- open components.tsx file at the root folder
- or /components/index.tsx file from the root folder

You have neither of those files existing right now.

If you want to import CarDetails, you need to do: @/components/CarDetails
for imports you should just wait after typing "/" for vscode to show u files dropdown, that is best
^^
Yup! thanks