TypeError: Cannot read properties of undefined (reading 'clientModules')
Answered
Thrianta posted this in #help-forum
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 perfectly37 Replies
Hong
@Thrianta Have you tried to build your app locally? Can you provide the full error with the stack traces?
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
Hong
what? Can you run like
npm run build
?ThriantaOP
yup
no error when building locally
Hong
Try to redeploy it, maybe.
ThriantaOP
build task passes, every other page also works fine, just this single page shows up with an error
Hong
Oh, can you provide the code for this page?
ThriantaOP
yup, gimme a sec
Hong
Why are you using
'use server'
here?I think removing it can fix the problem.
ThriantaOP
that is there to just make sure the database function is not exported to the client
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.
ThriantaOP
but having
'use server'
should not really change anything anywaysbesides, if that was the case why would it work locally
joulev
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
ThriantaOP
i am on the latest version i think,
14.1.0
joulev
seems related to this https://github.com/vercel/next.js/pull/60776
oh it's not in stable yet, only in canary
try canary then. v14.1.1-canary.10
ThriantaOP
lemme try
ThriantaOP
still same error after updating nextjs version, trying after removing build cache
joulev
then im out of idea, sorry
it's working fine in my end
ThriantaOP
exactly, locally it is working perfectly fine
not working even after removing build cache
Hong
Do you set the env variables on vercel?
ThriantaOP
yup
Hong
Then, I have no idea. ðŸ«
ThriantaOP
same
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
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 perfectlyAnswer
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