Build Error: Module not found
Unanswered
thatguy posted this in #help-forum
thatguyOP
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'
Here’s the error:
./src/app/(user)/shop/page.jsx:3:1
Module not found: Can't resolve '../../lib/sanityClient'
9 Replies
Tomistoma
Is the lib folder inside your app folder or inside your src?
thatguyOP
inside the src folder
Thrianta
Can you screenshot or paste the code from shop/page.tsx and screen shot your expanded file structure please
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
Thrianta
^ likely so, let me know if you dont have custom imports, the @ really helps when you miss count the path jumps
thatguyOP
It worked. Thanks man. You just saved th rest of my day
Tomistoma
No prob. Glad it worked.
thatguyOP
It's crazy how simply errors like this can ruin your whole day
Tomistoma
It do be like that sometimes even in the best of us