I am trying to create a build of my nextjs project but it keeps on failing and showing the below error where as it works perfectly during development. I haven’t used the ‘window.’ in my whole project but still getting its error, I tried cleaning the project by deleting its .next and node_modules but it didn’t work.
<code>ReferenceError: window is not defined
at 22462 (path/.next/server/chunks/414.js:5:949)
> Export encountered errors on following paths:
/dashboard/leads/did-not-hire/page: /dashboard/leads/did-not-hire
</code>
<code>ReferenceError: window is not defined
at 22462 (path/.next/server/chunks/414.js:5:949)
> Export encountered errors on following paths:
/dashboard/leads/did-not-hire/page: /dashboard/leads/did-not-hire
</code>
ReferenceError: window is not defined
at 22462 (path/.next/server/chunks/414.js:5:949)
> Export encountered errors on following paths:
/dashboard/leads/did-not-hire/page: /dashboard/leads/did-not-hire
/dashboard/leads/did-not-hire/page
<code>"use client";
import { listLeads } from "@/actions/leads";
import {
Flex,
Grid,
LeadCard,
SpinnerMedium,
Text2Xl,
} from "@/components/commons";
import { routes } from "@/config";
import { faArrowLeft } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { useRouter } from "next/navigation";
import React, { useEffect, useState } from "react";
export const dynamic = "force-dynamic";
export const fetchCache = "force-no-store";
const DidNotHire = () => {
const router = useRouter();
const [leads, setLeads] = useState([]);
const [isLoading, setIsLoading] = useState(true);
const getDidNotHireLeads = async () => {
setIsLoading(true);
const obj = {
filter: "is_hired.eq.0",
};
const { data, success } = await listLeads(obj);
setIsLoading(false);
if (success) {
setLeads(data);
}
};
useEffect(() => {
getDidNotHireLeads();
}, []);
return (
<>
<Flex justify="justify-start">
<button type="button" onClick={() => router.push(routes.leads.index)}>
<Flex classes="bg-white w-10 h-10 rounded-full">
<FontAwesomeIcon icon={faArrowLeft} />
</Flex>
</button>
<Text2Xl text="Did Not Hire" />
</Flex>
{isLoading ? (
<Flex classes="h-[60vh]">
<SpinnerMedium fill="fill-black" />
</Flex>
) : (
<Grid classes="my-8">
{leads.map((lead) => {
return (
<div
key={lead.id}
className="col-span-12 md:col-span-6 lg:col-span-4 xl:col-span-3"
>
<LeadCard
bgColor="bg-did-not-hire"
lead={lead}
setLeads={setLeads}
showActions={false}
/>
</div>
);
})}
</Grid>
)}
</>
);
};
export default DidNotHire;
</code>
<code>"use client";
import { listLeads } from "@/actions/leads";
import {
Flex,
Grid,
LeadCard,
SpinnerMedium,
Text2Xl,
} from "@/components/commons";
import { routes } from "@/config";
import { faArrowLeft } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { useRouter } from "next/navigation";
import React, { useEffect, useState } from "react";
export const dynamic = "force-dynamic";
export const fetchCache = "force-no-store";
const DidNotHire = () => {
const router = useRouter();
const [leads, setLeads] = useState([]);
const [isLoading, setIsLoading] = useState(true);
const getDidNotHireLeads = async () => {
setIsLoading(true);
const obj = {
filter: "is_hired.eq.0",
};
const { data, success } = await listLeads(obj);
setIsLoading(false);
if (success) {
setLeads(data);
}
};
useEffect(() => {
getDidNotHireLeads();
}, []);
return (
<>
<Flex justify="justify-start">
<button type="button" onClick={() => router.push(routes.leads.index)}>
<Flex classes="bg-white w-10 h-10 rounded-full">
<FontAwesomeIcon icon={faArrowLeft} />
</Flex>
</button>
<Text2Xl text="Did Not Hire" />
</Flex>
{isLoading ? (
<Flex classes="h-[60vh]">
<SpinnerMedium fill="fill-black" />
</Flex>
) : (
<Grid classes="my-8">
{leads.map((lead) => {
return (
<div
key={lead.id}
className="col-span-12 md:col-span-6 lg:col-span-4 xl:col-span-3"
>
<LeadCard
bgColor="bg-did-not-hire"
lead={lead}
setLeads={setLeads}
showActions={false}
/>
</div>
);
})}
</Grid>
)}
</>
);
};
export default DidNotHire;
</code>
"use client";
import { listLeads } from "@/actions/leads";
import {
Flex,
Grid,
LeadCard,
SpinnerMedium,
Text2Xl,
} from "@/components/commons";
import { routes } from "@/config";
import { faArrowLeft } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { useRouter } from "next/navigation";
import React, { useEffect, useState } from "react";
export const dynamic = "force-dynamic";
export const fetchCache = "force-no-store";
const DidNotHire = () => {
const router = useRouter();
const [leads, setLeads] = useState([]);
const [isLoading, setIsLoading] = useState(true);
const getDidNotHireLeads = async () => {
setIsLoading(true);
const obj = {
filter: "is_hired.eq.0",
};
const { data, success } = await listLeads(obj);
setIsLoading(false);
if (success) {
setLeads(data);
}
};
useEffect(() => {
getDidNotHireLeads();
}, []);
return (
<>
<Flex justify="justify-start">
<button type="button" onClick={() => router.push(routes.leads.index)}>
<Flex classes="bg-white w-10 h-10 rounded-full">
<FontAwesomeIcon icon={faArrowLeft} />
</Flex>
</button>
<Text2Xl text="Did Not Hire" />
</Flex>
{isLoading ? (
<Flex classes="h-[60vh]">
<SpinnerMedium fill="fill-black" />
</Flex>
) : (
<Grid classes="my-8">
{leads.map((lead) => {
return (
<div
key={lead.id}
className="col-span-12 md:col-span-6 lg:col-span-4 xl:col-span-3"
>
<LeadCard
bgColor="bg-did-not-hire"
lead={lead}
setLeads={setLeads}
showActions={false}
/>
</div>
);
})}
</Grid>
)}
</>
);
};
export default DidNotHire;