Next.js Discord

Discord Forum

TypeError: Cannot read properties of undefined (reading 'clientModules')

Answered
Thrianta posted this in #help-forum
Open in Discord
Avatar
ThriantaOP
Hey, i am getting this error when deploying to vercel, locally everything works just as expected, when deployed to vercel in prod, i get this error and the page returns this error
Answered by Thrianta
This error was after all due to vercel and not nextjs itself, vercel was not able to find client-manifest.json and other stuff for that specific route apparently something with build, after building locally and uploading the build it works perfectly
View full answer

37 Replies

Avatar
Hong
@Thrianta Have you tried to build your app locally? Can you provide the full error with the stack traces?
Avatar
ThriantaOP
lemme try building locally, because on dev server it works fine
⨯ TypeError: Cannot read properties of undefined (reading 'clientModules')
    at /var/task/node_modules/.pnpm/next@14.1.0_@opentelemetry+api@1.7.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:199008
    at rW (/var/task/node_modules/.pnpm/next@14.1.0_@opentelemetry+api@1.7.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:16:14861)
    at nM (/var/task/node_modules/.pnpm/next@14.1.0_@opentelemetry+api@1.7.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:47419)
    at nN (/var/task/node_modules/.pnpm/next@14.1.0_@opentelemetry+api@1.7.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:64674)
    at nG (/var/task/node_modules/.pnpm/next@14.1.0_@opentelemetry+api@1.7.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:72265)
    at AsyncLocalStorage.run (node:async_hooks:338:14)
    at Timeout._onTimeout (/var/task/node_modules/.pnpm/next@14.1.0_@opentelemetry+api@1.7.0_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:12:88128)
    at listOnTimeout (node:internal/timers:569:17)
    at process.processTimers (node:internal/timers:512:7) {
  page: '/profile/835137181504372806'
}


This is the stack trace in vercel dashboard
i can't build locally but not because of this but another bug with vercel CLI
Avatar
Hong
what? Can you run like npm run build?
Avatar
ThriantaOP
yup
no error when building locally
Avatar
Hong
Try to redeploy it, maybe.
Avatar
ThriantaOP
build task passes, every other page also works fine, just this single page shows up with an error
Avatar
Hong
Oh, can you provide the code for this page?
Avatar
ThriantaOP
yup, gimme a sec
Image
Avatar
Hong
Why are you using 'use server' here?
I think removing it can fix the problem.
Avatar
ThriantaOP
that is there to just make sure the database function is not exported to the client
Avatar
Hong
To my knowledge, this code will only run on the server. I mean it's server-side rendering. It will not be exposed to the client side.
Avatar
ThriantaOP
but having 'use server' should not really change anything anyways
besides, if that was the case why would it work locally
Avatar
joulev & fuma pray for Schneider
try upgrading nextjs version and redeploy without cache
i've seen scattered reports of this error which are fixed by updating versions and/or clearing .next
Avatar
ThriantaOP
i am on the latest version i think, 14.1.0 :fine:
Avatar
joulev & fuma pray for Schneider
oh it's not in stable yet, only in canary
try canary then. v14.1.1-canary.10
Avatar
ThriantaOP
lemme try
Avatar
ThriantaOP
still same error after updating nextjs version, trying after removing build cache
Avatar
joulev & fuma pray for Schneider
then im out of idea, sorry
it's working fine in my end
Avatar
ThriantaOP
exactly, locally it is working perfectly fine
not working even after removing build cache
Avatar
Hong
Do you set the env variables on vercel?
Avatar
ThriantaOP
yup
Avatar
Hong
Then, I have no idea. 🫠
Avatar
ThriantaOP
:fine: same
Avatar
ThriantaOP
for debug purposes i created a dummy api route where i was returning the user data to check if the database is causing this error, that route returned response just fine so that is not causing this error either
Avatar
ThriantaOP
This error was after all due to vercel and not nextjs itself, vercel was not able to find client-manifest.json and other stuff for that specific route apparently something with build, after building locally and uploading the build it works perfectly
Answer
Avatar
Ant
I resolved this issue by removing my Route Groups, that's folders that look like this '(folderName)' - these guys: https://nextjs.org/docs/app/building-your-application/routing/route-groups