Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

next.js

The project's pages work fine with npm run dev and I do not get these errors with the pages with vercel --prod. The problems show up when I generate a production build and run the app with next start.

With [email protected] I got TypeError: Cannot read properties of undefined (reading 'ppr') so I downgraded to [email protected]. Now I am getting multiple instances of TypeError: Cannot read properties of undefined (reading 'clientModules')

TypeError: Cannot read properties of undefined (reading 'clientModules') at u (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:108:22420) at /Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:108:23409 at nk (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:38654) at nC (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:54802) at nk (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:51563) at nC (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:54802) at nw (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:38210) at nk (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:38805) at nC (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:54802) at nk (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:51563) TypeError: Cannot read properties of undefined (reading 'clientModules') at u (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:108:22420) at /Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:108:23409 at nk (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:38654) at nC (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:54802) at nj (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:60948) at AsyncLocalStorage.run (node:async_hooks:346:14) at Timeout._onTimeout (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:76278) at listOnTimeout (node:internal/timers:573:17) at process.processTimers (node:internal/timers:514:7) TypeError: Cannot read properties of undefined (reading 'clientModules') at u (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:108:22420) at /Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:108:23409 at nk (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:38654) at nC (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:54802) at nj (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:60948) at AsyncLocalStorage.run (node:async_hooks:346:14) at Timeout._onTimeout (/Users/donovanwhite/art_folio/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:28:76278) at listOnTimeout (node:internal/timers:573:17) at process.processTimers (node:internal/timers:514:7)

like image 528
dwhynot Avatar asked Mar 15 '26 11:03

dwhynot


2 Answers

The issue that I had was that my routes were conflicting. I had one folder that was (homepage), meaning that the route was effectively "/". However, I also left a page.tsx file in the root directory, which had "/" as its route as well. Make sure that you don't have any overlap between folders that aren't included in the route structure and their root folders.

like image 68
Luke Steinbicker Avatar answered Mar 17 '26 02:03

Luke Steinbicker


I had this problem few days ago, for context i was converting my Vite-React-SPA to NextJS for SSR and SSG, then also host it on Vercel (the Vite version was already hosted).

I found the problem from restructuring the filepaths (I was using App router), then i run debug. It's painful way of doing it yes. but i did found the problem.

on my file arch app/(group_folder)/@footer/page, there was a missing import statement here. AND because it was not in the root app/ where homepage(/page) was located, it causes build error for some reason. So the idea was if you're using @slots then don't put them inside other folders and keep them in the root folder of your pages along with the /page.js*jsx.

like this

~app/page.jsx
~app/@footer/page.jsx
~app/@navigation/page.jsx

that's how i fixed this error

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

Since Im new to this and don't understand the intricacies of server and client components yet i may be wrong with this approach so if anyone can edit this so its more readable i would be more than glad.

like image 21
dayumsonwheredyoufindtihs Avatar answered Mar 17 '26 04:03

dayumsonwheredyoufindtihs



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!