Im getting this error when I
m trying to build my app but when I run it on my pc everything is fine. what is the issue?
import clientPromise from "@/lib/mongodb";
import { ObjectId } from "mongodb";
export async function findIsomoById(itemId: string) {
try {
// Connect to the MongoDB database
const client = await clientPromise;
const db = client.db("amasomo_ya_misa");
const collection = db.collection("amasomo");
console.log(new ObjectId(itemId));
// Find the item in the collection by its _id
const isomo = await collection.findOne({ _id: new ObjectId(itemId) });
return isomo;
} catch (error) {
console.error(error);
throw new Error("An error occurred while finding the item.");
} finally {
//ServerClosedEvent.apply;
}
}
[= ] info - Generating static pages (3/4)BSONTypeError: Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer
at new BSONTypeError (C:\Users\InezaGuy\reactpr\amasomo_yamisa\node_modules\bson\lib\error.js:41:28)
at new ObjectId (C:\Users\InezaGuy\reactpr\amasomo_yamisa\node_modules\bson\lib\objectid.js:67:23)
at findIsomoById (C:\Users\InezaGuy\reactpr\amasomo_yamisa\.next\server\app\isomo\[id]\page.js:553:21)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async AmasomoReview (C:\Users\InezaGuy\reactpr\amasomo_yamisa\.next\server\app\isomo\[id]\page.js:573:19)
Error: An error occurred while finding the item.
at findIsomoById (C:\Users\InezaGuy\reactpr\amasomo_yamisa\.next\server\app\isomo\[id]\page.js:561:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async AmasomoReview (C:\Users\InezaGuy\reactpr\amasomo_yamisa\.next\server\app\isomo\[id]\page.js:573:19)
Error occurred prerendering page "/isomo/[id]". Read more: https://nextjs.org/docs/messages/prerender-error
Error: An error occurred while finding the item.
at findIsomoById (C:\Users\InezaGuy\reactpr\amasomo_yamisa\.next\server\app\isomo\[id]\page.js:561:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async AmasomoReview (C:\Users\InezaGuy\reactpr\amasomo_yamisa\.next\server\app\isomo\[id]\page.js:573:19)
info - Generating static pages (4/4)