Next.js Discord

Discord Forum

Build Error: Module not found

Unanswered
thatguy posted this in #help-forum
Open in Discord
Avatar
Hi everyone, I’m getting a "Module not found: Can't resolve '../../lib/sanityClient'" error when trying to build my Next.js 14 project. The path is correct, and I’ve tried cleaning the cache and updating Next.js, but the issue persists. Any ideas on what might be causing this?

Here’s the error:

./src/app/(user)/shop/page.jsx:3:1
Module not found: Can't resolve '../../lib/sanityClient'

9 Replies

Avatar
Tomistoma
Is the lib folder inside your app folder or inside your src?
Avatar
inside the src folder
Avatar
Thrianta
Can you screenshot or paste the code from shop/page.tsx and screen shot your expanded file structure please
Avatar
Tomistoma
It seems the import is wrong because '../../lib/sanityClient' relative to ./src/app/(user)/shop/page.jsx is saying lib/sanityClient is in the app folder. You need to adjust it to ../../../lib/sanityClient or better yet @/lib/sanityClient
Avatar
Thrianta
^ likely so, let me know if you dont have custom imports, the @ really helps when you miss count the path jumps
Avatar
It worked. Thanks man. You just saved th rest of my day
Avatar
Tomistoma
No prob. Glad it worked.
Avatar
It's crazy how simply errors like this can ruin your whole day
Avatar
Tomistoma
It do be like that sometimes even in the best of us